#2917: alloca and allocaArray do not respect alignment
-----------------------------+----------------------------------------------
  Reporter:  guest           |          Owner:                  
      Type:  bug             |         Status:  new             
  Priority:  normal          |      Milestone:  _|_             
 Component:  Compiler (FFI)  |        Version:  6.12.3          
Resolution:                  |       Keywords:                  
  Testcase:                  |      Blockedby:                  
Difficulty:  Unknown         |             Os:  Unknown/Multiple
  Blocking:                  |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown    |  
-----------------------------+----------------------------------------------

Comment(by Lemming):

 For a wrapper around 'malloc' we could waste less memory, if we would
 require that 'free' has a Storable constraint and requires that its
 pointer type matches the one of the corresponding 'malloc'. With the size
 and alignment information, 'malloc' and 'free' could decide whether to pad
 at all. Even if they pad, they can save memory by putting the pointer to
 full allocated block ''after'' the block of aligned data. E.g. compare the
 layout, where 'p' is a byte of the pointer to the full allocated block,
 'a' is a byte of 16-byte aligned data, and '*' is allocated but unused
 (=wasted) padding byte.
 {{{
 0           0   1               2              2
 0           C   0               0              F
 ************ppppaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

 0               1               2  2
 0               0               0  3
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaapppp
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2917#comment:25>
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

Reply via email to