Skip to content

Commit 948cf7b

Browse files
committed
adding NOINLINE to fix a bug of -XStrict.
1 parent 6ce153b commit 948cf7b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Network/Socket/Types.hsc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,7 @@ class SocketAddress sa where
10071007
sockaddrStorageLen :: Int
10081008
sockaddrStorageLen = 128
10091009

1010+
{-# NOINLINE withSocketAddress #-}
10101011
withSocketAddress :: SocketAddress sa => sa -> (Ptr sa -> Int -> IO a) -> IO a
10111012
withSocketAddress addr f = do
10121013
let sz = sizeOfSocketAddress addr
@@ -1114,6 +1115,9 @@ sizeOfSockAddr SockAddrUnix{} = #const sizeof(struct sockaddr_un)
11141115
sizeOfSockAddr SockAddrInet{} = #const sizeof(struct sockaddr_in)
11151116
sizeOfSockAddr SockAddrInet6{} = #const sizeof(struct sockaddr_in6)
11161117

1118+
-- The combination of "-XString" and inlining results in a bug where
1119+
-- "sz" is always 0.
1120+
{-# NOINLINE withSockAddr #-}
11171121
-- | Use a 'SockAddr' with a function requiring a pointer to a
11181122
-- 'SockAddr' and the length of that 'SockAddr'.
11191123
withSockAddr :: SockAddr -> (Ptr SockAddr -> Int -> IO a) -> IO a

0 commit comments

Comments
 (0)