From 03c368158ee0e84b0f4a8d4ac6a16289f4121fd4 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 16 Mar 2024 17:07:50 +0000 Subject: [PATCH] [std.socket] Fix cast assign to getaddrinfoPointer See https://github.com/dlang/dmd/pull/16315 With that pull, using a type qualifier cast is not @safe to use as an lvalue. --- std/socket.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/std/socket.d b/std/socket.d index 4052479f9ca..b2570f596ca 100644 --- a/std/socket.d +++ b/std/socket.d @@ -1116,7 +1116,7 @@ Address[] getAddress(scope const(char)[] hostname, ushort port) // test via gethostbyname auto getaddrinfoPointerBackup = getaddrinfoPointer; cast() getaddrinfoPointer = null; - scope(exit) cast() getaddrinfoPointer = getaddrinfoPointerBackup; + scope(exit) () @trusted { cast() getaddrinfoPointer = getaddrinfoPointerBackup; }(); addresses = getAddress("63.105.9.61"); assert(addresses.length && addresses[0].toAddrString() == "63.105.9.61"); @@ -1196,7 +1196,7 @@ Address parseAddress(scope const(char)[] hostaddr, ushort port) // test via inet_addr auto getaddrinfoPointerBackup = getaddrinfoPointer; cast() getaddrinfoPointer = null; - scope(exit) cast() getaddrinfoPointer = getaddrinfoPointerBackup; + scope(exit) () @trusted { cast() getaddrinfoPointer = getaddrinfoPointerBackup; }(); address = parseAddress("63.105.9.61"); assert(address.toAddrString() == "63.105.9.61"); @@ -1698,7 +1698,7 @@ public: // test reverse lookup, via gethostbyaddr auto getnameinfoPointerBackup = getnameinfoPointer; cast() getnameinfoPointer = null; - scope(exit) cast() getnameinfoPointer = getnameinfoPointerBackup; + scope(exit) () @trusted { cast() getnameinfoPointer = getnameinfoPointerBackup; }(); assert(ia.toHostNameString() == "digitalmars.com"); } @@ -1716,7 +1716,7 @@ public: // test failing reverse lookup, via gethostbyaddr auto getnameinfoPointerBackup = getnameinfoPointer; cast() getnameinfoPointer = null; - scope(exit) cast() getnameinfoPointer = getnameinfoPointerBackup; + scope(exit) () @trusted { cast() getnameinfoPointer = getnameinfoPointerBackup; }(); assert(ia.toHostNameString() is null); }