GCC Bugzilla – Bug 21336
[3.4 Regression] Internal compiler error when using custom new operators
Last modified: 2005-06-03 16:31:11 UTC
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'
Created attachment 8793 [details] Preprocessed file Preprocessed file as mentioned in bug description
Confirmed, a 3.4 regression also. Reduced testcase: typedef __SIZE_TYPE__ size_t; template<class _T> inline void* operator new( size_t Size, _T&); struct B { int a; int* m() { return new(a) int; } }; B* n() { return new B(); }
The ICE started : Search converges between 2004-01-17-trunk (#438) and 2004-01-23-trunk (#439).
Subject: Bug 21336 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2005-06-03 16:16:47 Modified files: gcc/cp : cp-tree.h decl.c pt.c ChangeLog gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: new2.C Log message: PR c++/21336 * cp-tree.h (grok_op_properties): Remove friendp parameter. * decl.c (grokfndecl): Adjust call. (grok_op_properties): Determine the class of which the function is a member by looking at its DECL_CONTEXT, not current_class_type. * pt.c (tsubst_decl): Adjust call to grok_op_properties. PR c++/21336 * g++.dg/template/new2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1139&r2=1.1140 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1402&r2=1.1403 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.1000&r2=1.1001 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4772&r2=1.4773 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5585&r2=1.5586 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/new2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 21336 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: mmitchel@gcc.gnu.org 2005-06-03 16:18:54 Modified files: gcc/cp : cp-tree.h decl.c pt.c ChangeLog gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: new2.C Log message: PR c++/21336 * cp-tree.h (grok_op_properties): Remove friendp parameter. * decl.c (grokfndecl): Adjust call. (grok_op_properties): Determine the class of which the function is a member by looking at its DECL_CONTEXT, not current_class_type. * pt.c (tsubst_decl): Adjust call to grok_op_properties. PR c++/21336 * g++.dg/template/new2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1106.2.6&r2=1.1106.2.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1371.2.13&r2=1.1371.2.14 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.978.2.11&r2=1.978.2.12 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.55&r2=1.4648.2.56 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.221&r2=1.5084.2.222 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/new2.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Fixed in 4.0, 4.1.
Subject: Bug 21336 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2005-06-03 16:29:36 Modified files: gcc/cp : cp-tree.h decl.c pt.c ChangeLog gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: new2.C Log message: PR c++/21336 * cp-tree.h (grok_op_properties): Remove friendp parameter. * decl.c (grokfndecl): Adjust call. (grok_op_properties): Determine the class of which the function is a member by looking at its DECL_CONTEXT, not current_class_type. * pt.c (tsubst_decl): Adjust call to grok_op_properties. PR c++/21336 * g++.dg/template/new2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.946.4.20&r2=1.946.4.21 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.34&r2=1.1174.2.35 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.53&r2=1.816.2.54 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.220&r2=1.3892.2.221 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.399&r2=1.3389.2.400 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/new2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.4.1
Fixed in 3.4.5.