On Thu, Jan 8, 2009 at 11:38 AM, Ian Lance Taylor <i...@google.com> wrote: >> For the memory allocator writers, they should provide an interface >> with a parameter to specify alignment requirement. User can use >> __attribute__ ((aligned (XXX))) to tell compiler memory alignment. > > Think harder about new[] and auto-vectorization. What you describe > seems to me to be a theoretical argument rather than a practical one. > > Ian >
This problem is basically: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36159 We can solve it with 1. A target should define MALLOC_ABI_ALIGNMENT properly. 2. g++ should issue an error when the default new operator is used on a type whose alignment is greater than MALLOC_ABI_ALIGNMENT. 3. It is user's responsibility to provide a new operator to return a properly aligned memory. 4. g++ can assume memory return by the user-provided new operator is properly aligned. -- H.J.