alloca and allocaArray do not respect alignment
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
Trac metadata
Trac field | Value |
---|---|
Version | 6.10.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (FFI) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | lennart@augustsson.net |
Operating system | |
Architecture | x86 |