summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts/overflow1.hs
blob: 74a396bc5323f17370078628909bcedbaf8e9810 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE UnboxedTuples #-}

module Main where

import GHC.Exts
import GHC.Base

-- Try to overflow BLOCK_ROUND_UP in the computation of req_blocks in allocate()
-- Here we invoke allocate() via newByteArray#.
-- Request a number of bytes close to HS_WORD_MAX,
-- subtracting a few words for overhead in newByteArray#.
main :: IO ()
main =
    IO $ \s1# ->
           case newByteArray# (maxInt# -# 10#) s1# of
             (# s2#, _ #) -> (# s2#, () #)
  where
    maxInt# :: Int#
    !(I# maxInt#) = maxBound