[Bug c++/15795] No way to teach operator new anything about alignment requirements

jason at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu Jun 3 23:02:00 GMT 2004


------- Additional Comments From jason at gcc dot gnu dot org  2004-06-03 23:01 -------
Yes, the bug is in malloc.

>From C99 7.20.3, talking about malloc/realloc:

The pointer returned if the allocation succeeds is suitably aligned so that
it may be assigned to a pointer to any type of object and then used to
access such an object or an array of such objects in the space allocated
(until the space is explicitly deallocated).

The rule for operator new is identical.  In this case, the pointer returned by
malloc, and thence by operator new, is not suitably aligned for a vector, so the
program segfaults.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15795



More information about the Gcc-bugs mailing list