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 ma1flfs at bath dot ac dot uk  2004-06-08 18:45 -------
Well, the workaround is a good idea in general, however, this program still 
segfaults... 
 
#define _XOPEN_SOURCE 600 
#include <xmmintrin.h> 
#include <stdio.h> 
#include <stdlib.h> 
 
class Vector4 
{ 
public: 
	__m128 vec; 
	 
	Vector4() 
	{ 
		vec = _mm_setzero_ps(); 
	} 
	 
	void *operator new (unsigned int s) 
	{ 
		void *p; 
		posix_memalign(&p, 16, s); 
		return p; 
  	} 
	 
	void *operator new[] (unsigned int s) 
	{ 
		return operator new (s); 
	} 
}; 
 
class Foo 
{ 
public: 
	Vector4 b; 
 
	Foo() {} 
}; 
 
int main(int argc, char **argv) 
{ 
	Foo *f = new Foo[200*200]; 
	 
	delete f; 
} 
 

-- 


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]