This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/15795] No way to teach operator new anything about alignment requirements


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]