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-04 09:33 -------
Disclaimer: I don't know that much about gcc, but I have some ideas anyway. 
 
As far as I can see there are two issues: 
Issue 1) 
__m128 *foo = new __m128; 
 
I don't think there is any excuse for this, it's just plain wrong that it 
doesn't work. __m128 is an intrinsic gcc is supposed to support. One thing 
about this intrinsic is that it's 128 bits long, the other, equally important 
is that it is aligned to a 16 byte boundary. 
If using malloc() to allocate that *foo, I would kindof expect failure, as 
malloc returns void* and thus does not know anything about what it allocates. 
however, new is a c++ keyword, i.e. part of c++. It should know what the hell 
it is allocating. 
In this case we ask it to allocate an object of type __m128. It DOES NOT 
allocate an object of type __m128. It just allocates something that is long 
enough. 
 
Issue 2) 
class { 
	float a; 
	__m128 b; 
} Foo; 
 
This is not that hard either, as sizeof(Foo) = 32. It already works if 
you allocate Foo on the stack. But the same problem as above remains. 
 
If you don't want to "fix" new, how about a C++ extension, so that you can tell 
new how to allocate objects...? 
Or failing that, emit a warning, telling the confused user about this IMHO 
weird behavior. 
 
Cheers, 
 
        Florian 

-- 


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]