summaryrefslogtreecommitdiff
path: root/libraries/base/tests/IO/T17414.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/tests/IO/T17414.hs')
-rw-r--r--libraries/base/tests/IO/T17414.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/libraries/base/tests/IO/T17414.hs b/libraries/base/tests/IO/T17414.hs
new file mode 100644
index 0000000000..59d40720ec
--- /dev/null
+++ b/libraries/base/tests/IO/T17414.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+import Foreign.Ptr (Ptr)
+import Foreign.Marshal.Alloc (mallocBytes, free)
+import System.IO (hPutBuf, withBinaryFile, IOMode (WriteMode))
+
+-- more than 2GiB
+numBytes :: Int
+numBytes = 2264375889
+
+main :: IO ()
+main = do
+ (ptr :: Ptr ()) <- mallocBytes numBytes
+ -- the next line produces the exception on macOS
+ withBinaryFile "test.out" WriteMode (\h -> hPutBuf h ptr numBytes)
+ free ptr
+
+ -- Truncate file in case it doesn't get deleted
+ writeFile "test.out" ""