This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: aligned attribute and the new operator (pr/15795)
- From: Ian Lance Taylor <iant at google dot com>
- To: trevor_smigiel at playstation dot sony dot com
- Cc: gcc at gcc dot gnu dot org
- Date: 10 Oct 2006 09:41:59 -0700
- Subject: Re: aligned attribute and the new operator (pr/15795)
- References: <20061010010443.GM24220@playstation.sony.com>
trevor_smigiel@playstation.sony.com writes:
> - the default versions of operator new and the aligned version of
> operator new should be defined in the same section. That way,
> when a user overrides the default operator new, they will get
> a link error (duplicate definitions of new) unless they also
> define the aligned version of operator new.
That would be a bad idea since it would break standard conformant
programs which only override the default operator new.
You are implicitly assuming that we know the alignment of memory
returned by new. If we know that, then whenever we need aligned
memory, we can ask for a bit more memory and force the alignment.
That will always work and avoids the concerns of overriding new. We
can generate more optimal code by providing a command line option
which specifies the alignment of memory returned by new.
Ian