The following piece of code crashes both my custom built gcc 4.0.0 (straight
from an official mirror) and gcc 4.0.0-0.41.fc3 from Red Hat. The code is a
reconstruction of a piece of propriatary code I cannot post. 

CODE:
typedef unsigned int size_t;

class A;
class B;
class C;

template<class _T> inline void* operator new( size_t Size, _T&);
template<class _T> inline void operator delete( void*, _T&);

class Abase {};
class A : public Abase {
public:
        A() {}
        A(int a, int b, int c, int d) {}
};

class Bbase {};
class B : public Bbase {
public:
        Abase* m() {
                return new(a) A(1,2,3,4);
        }
        A a;
};

class C {
public:
        Bbase* n() {
                return new B();
        }
};

GCC OUTPUT:
main.cpp: In member function ‘Bbase* C::n()’:
main.cpp:29: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccUR3mvM.out file, please attach this to
your bugreport.

OTHER COMPILERS:
MSVC++ 7.0 compiles the code above without warnings.

gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.fc3) returns this:
main.cpp: In member function `Bbase* C::n()':
main.cpp:29: error: no suitable or ambiguous `operator new' found in class `B'

-- 
           Summary: Internal compiler error when using custom new operators
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: moudekotte at khaeon dot nl
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-redhat-linux
GCC target triplet: i386-redhat-linux


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

Reply via email to