Skip to content

Commit

Permalink
[std.socket] Fix cast assign to getaddrinfoPointer
Browse files Browse the repository at this point in the history
See dlang/dmd#16315

With that pull, using a type qualifier cast is not @safe to use as an
lvalue.
  • Loading branch information
ntrel committed Mar 16, 2024
1 parent 0b45fc7 commit 932a4ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions std/socket.d
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 932a4ab

Please sign in to comment.