This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15795] No way to teach operator new anything about alignment requirements
- From: "jason at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jun 2004 18:05:36 -0000
- Subject: [Bug c++/15795] No way to teach operator new anything about alignment requirements
- References: <20040603143635.15795.ma1flfs@bath.ac.uk>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From jason at redhat dot com 2004-06-08 18:05 -------
Subject: Re: No way to teach operator new anything about
alignment requirements
And again, without the extra whitespace (sorry):
#include <xmmintrin.h>
#include <stdio.h>
#include <stdlib.h>
#include <new>
class Vector4
{
public:
Vector4() { vec = _mm_setzero_ps(); }
void *operator new (size_t);
void *operator new[] (size_t size) { return operator new (size); }
__m128 vec;
};
void *Vector4::operator new (size_t size)
{
void *p;
int r = posix_memalign (&p, __alignof (Vector4), size);
if (r)
throw std::bad_alloc ();
return p;
}
int main(int argc, char **argv)
{
Vector4 *foo = new Vector4[200*200];
delete foo;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15795