Ticket #2917 (new bug)
alloca and allocaArray do not respect alignment
| Reported by: | guest | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | _|_ |
| Component: | Compiler (FFI) | Version: | 6.12.3 |
| Keywords: | Cc: | lennart@…, danieldiaz@…, ghc@…, dterei | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
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
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

