The compiler asked me to submit a bug report. This is the first time, I am doing this, so please be patient. I am using gcc-3.4.0 (April 20) on Linux 2.4.24. The following very small file triggers an internal error. I do not claim the code to be valid. It does not include any other files. // minimal trigger template < typename T > class SmartPtr {}; template < typename T > void operator delete ( void* raw ) { delete raw; } class A { }; int main() { A* a = new A; delete a; } // end of file Here is what the compiler prints before dying: gcc-3.4.0-killer.cc: In function `int main()': gcc-3.4.0-killer.cc:15: internal compiler error: in c_expand_expr, at c-common.c :4138 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. Here is the output from gcc -v: Reading specs from /mnt/target/lfs/my_dist/shaddow/pkg/gcc-3.4.0/usr/bin/../lib/gcc/i686-pc-linux-gnu/3.4.0/specs Configured with: ./configure --prefix=/mnt/target/lfs/my_dist/shaddow/pkg/gcc-3.4.0/usr/ --enable-threads Thread model: posix gcc version 3.4.0 Here is the commandline: news_group> /mnt/target/lfs/my_dist/shaddow/pkg/gcc-3.4.0/usr/bin/g++ -I /usr/include -I /home/bux/bux/todo/towrite/c++ -Wall -pedantic gcc-3.4.0-killer.cc
Confirmed. It worked with 2.95, but never since. On active branches we get g/x> /home/bangerth/bin/gcc-3.3.4-pre/bin/c++ -c x.cc x.cc: In function `int main()': x.cc:13: internal compiler error: in c_expand_expr, at c-common.c:4341 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc x.cc: In function `int main()': x.cc:13: internal compiler error: in c_expand_expr, at c-common.c:4138 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc gimplification failed: <<< Unknown tree: template_decl >>> <template_decl 0x4026e828 operator delete type <function_type 0x40191c3c type <void_type 0x4018ea6c void type_6 VOID align 8 symtab 0 alias set -1 pointer_to_this <pointer_type 0x4018eae0>> QI size <integer_cst 0x4018f198 constant invariant 8> unit size <integer_cst 0x4018f030 constant invariant 1> align 8 symtab 0 alias set -1 arg-types <tree_list 0x4018f798 value <pointer_type 0x4018eae0> chain <tree_list 0x4018f3d8 tree_2 value <void_type 0x4018ea6c void>>> pointer_to_this <pointer_type 0x40270f68>> VOID file x.cc line 5 align 1 arguments <tree_list 0x4026d408 purpose <integer_cst 0x4018f030 1> value <tree_vec 0x4026d3f0 type <template_decl 0x4026e828 operator delete> elt 0 <tree_list 0x4026d3d8>>> result <function_decl 0x4026e7b4 operator delete type <function_type 0x40191c3c> public static decl_5 QI file x.cc line 5 arguments <parm_decl 0x4026e6cc raw type <pointer_type 0x4018eae0> used unsigned SI file x.cc line 5 size <integer_cst 0x4018f048 constant invariant 32> unit size <integer_cst 0x4018f0a8 constant invariant 4> align 32 context <function_decl 0x4026e7b4 operator delete>> result <result_decl 0x4026e89c type <void_type 0x4018ea6c void> VOID file x.cc line 5 align 8 context <function_decl 0x4026e7b4 operator delete>> initial <block 0x401fe2ec> template-info 0x4026d4f8 saved-insns 0x40210600> chain <template_decl 0x4026e414 SmartPtr>> x.cc: In function `int main()': x.cc:13: internal compiler error: in gimplify_expr, at gimplify.c:3626 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. W.
The code is invalid, btw: you can't declare operator delete a template this way (how is the compiler supposed to figure out the value of 'T'?). W.
> The code is invalid, btw: you can't declare operator delete a template > this way (how is the compiler supposed to figure out the value of 'T'?). > > W. Sure, but if you ditch that "template< typename T >", the error won't show :-) Kai-Uwe ps. I was mistaken about minimality. I forgot to take out the smart pointer template. Thus, this is shorter. It still triggers the internal error: template < typename T > void operator delete ( void* raw ) { delete raw; } class A { }; int main() { A* a = new A; delete a; }
> Sure, but if you ditch that "template< typename T >", the error > won't show :-) Right :-) This information is only important to us when determining which bugs need to be fixed first, and which are not that important because users can work around them by fixing their codes :-) W.
> > > The code is invalid, btw: you can't declare operator delete a template > > > this way (how is the compiler supposed to figure out the value of 'T'?). > > > > Sure, but if you ditch that "template< typename T >", the error > > won't show :-) > > Right :-) This information is only important to us when determining > which bugs need to be fixed first, and which are not that important > because users can work around them by fixing their codes :-) Fair enough. Then it might be of interest that the following code template < typename T > void operator delete ( void* raw ) {} int main() { void* a = new char; delete a; } compiles without triggering any warnings (I use -Wall -pedantic). And, I have no idea if a is actually being deleted or not. How did the compiler figure out the value of T? Or did it not look at the template at all? Before I forget, many thanks for looking into this and even helping me to understand my own crappy code. That's just great! I am still struggeling hard with the sheer complexity of C++ :-) Best regards Kai-Uwe
True, I just opened new PR 15898 for this. However, for this PR, the testcase in comment #3 is the one we're concerned about. W.
: Search converges between 2001-05-20-trunk (#20) and 2001-05-27-trunk (#21).
Subject: Bug 15890 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-08-19 20:16:03 Modified files: gcc/testsuite : ChangeLog gcc/cp : ChangeLog pt.c Added files: gcc/testsuite/g++.dg/template: delete1.C Log message: PR c++/15890 * pt.c (push_template_decl_real): Disallow template allocation functions with fewer than two parameters. PR c++/15890 * g++.dg/template/delete1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4161&r2=1.4162 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/delete1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4286&r2=1.4287 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.910&r2=1.911
Subject: Bug 15890 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-08-19 20:18:23 Modified files: gcc/cp : ChangeLog pt.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: delete1.C Log message: PR c++/15890 * pt.c (push_template_decl_real): Disallow template allocation functions with fewer than two parameters. PR c++/15890 * g++.dg/template/delete1.C: New test. Patches: 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.148&r2=1.3892.2.149 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.40&r2=1.816.2.41 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.251&r2=1.3389.2.252 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/delete1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.4.2.
*** Bug 15898 has been marked as a duplicate of this bug. ***