Ticket #2917 (new bug)
alloca and allocaArray do not respect alignment
|Reported by:||guest||Owned by:|
|Keywords:||Cc:||lennart@…, danieldiaz@…, ghc@…, dterei|
|Type of failure:||None/Unknown||Difficulty:||Unknown|
|Test Case:||Blocked By:|
When allocating memory with alloca or allocaArray the alignment of the Storable is not respected, alignment seems to be on 8 byte boundary. malloc and mallocArray seem to have the same problem. And because of this functions like withArray etc also break the alignment restriction of the array element.
Run this and look at the pointer.
import Foreign.Ptr import Foreign.Storable import Foreign.Marshal.Array import Foreign.Marshal data Foo = Foo instance Storable Foo where sizeOf _ = 8 alignment _ = 256 main = allocaArray 5 $ \ p -> do let _ = p :: Ptr Foo print p q <- mallocArray 5 let _ = q :: Ptr Foo print q