[EMAIL PROTECTED] tmp]$ cat a.cc
#include <stdio.h>
#include <emmintrin.h>

struct A {
public:
       __m128i m;
       void init() { m = _mm_setzero_si128(); }
};

int main()
{
       A * a = new A;
       printf("Address of A: %p\n", a);
       a->init();
       delete a;
       return 0;
}
[EMAIL PROTECTED] tmp]$ g++ -m32 -msse3 a.cc
[EMAIL PROTECTED] tmp]$ ./a.out
Address of A: 0x804a008
Segmentation fault
[EMAIL PROTECTED] tmp]$

If we add dynamic allocation with explicit alignment support to C++, we
immediately have to answer the question: does this extension require new
syntax?

If it doesn't -- in other words, if we just change the way code is generated
for a new-expression -- then some existing carefully-written code will be
broken.

If it does, then existing template code won't take advantage of it. So, for
example, if we store our SIMD data in a standard C++ library container, it
(probably) won't work because it won't be properly aligned.

This is the reason why no one has yet come up with a general solution to this
problem, even though it has been a known issue for over ten years. The best
that anyone's been able to do is the class-specific operator new.

For this testcase, g++ should issue an error when the class-specific operator
new is missing.


-- 
           Summary: C++ compiler should issue a warning with  missing new
                    operator
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hjl dot tools at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36159

Reply via email to