This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch]: new returns misaligned pointers
>>>>> "Diego" == Diego Novillo <dnovillo@cygnus.com> writes:
Diego> I agree, but in this case they were expecting new and
Diego> malloc to return the same alignment. That's the only reason
Diego> why we needed to change it.
There's nothing in the standard that says that. In fact, when the
compiler sees:
struct S { }; /* Double sized thing full of shorts */
new S;
it can give back short-aligned memory, even if `malloc' would normally
give back memory with enough alignment for a double.
Any program making the assumption you state is broken, I think.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com