#2917: alloca and allocaArray do not respect alignment
-----------------------------+----------------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler (FFI)
Version: 6.10.1 | Severity: normal
Keywords: | Testcase:
Os: Unknown/Multiple | Architecture: x86
-----------------------------+----------------------------------------------
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
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2917>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs