[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
Tue Jun 8 18:04:00 GMT 2004
------- Additional Comments From jason at gcc dot gnu dot org 2004-06-08 18:04 -------
Here is a more elegant workaround:
#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
More information about the Gcc-bugs
mailing list