{-# LANGUAGE Safe #-}
module Main where
import Foreign.Marshal.Alloc
import Foreign.Storable
import Foreign.Ptr
import System.Random
fn :: Ptr Int -> IO ()
fn p = do
-- This is kosher:
poke p 3
print =<< peek p
-- This should crash the system:
ix <- randomIO
pokeElemOff p ix 0xcc
main = alloca fn
```
-Ryan