The following invalid code snippet triggers an ICE: ====================================== struct A; namespace { struct A; } struct B {}; template<typename T> void foo(T t) { t.~A(); } void bar() { foo(B()); } ====================================== bug.cc: In function 'void foo(T)': bug.cc:8:6: error: reference to 'A' is ambiguous bug.cc:1:8: error: candidates are: struct A bug.cc:2:20: error: struct<unnamed>::A bug.cc: In function 'void foo(T) [with T = B]': bug.cc:13:10: instantiated from here bug.cc:8:3: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in check_dtor_name, at cp/call.c:247 Please submit a full bug report, [etc.] The bug affects the trunk, the 4.4 branch, and the 4.3 branch. The bug was introduced on the 4.3 branch after the release of GCC 4.3.3.
It is caused by revision 143502: http://gcc.gnu.org/ml/gcc-cvs/2009-01/msg00515.html
Created attachment 17967 [details] gcc45-pr40373.patch Possible fix.
WONTFIX for 4.3/4.4 branches.
I think it should be fixed in 4.3/4.4 since the bug wasn't present in 4.3.3 and the fix is trivial.
Subject: Bug 40373 Author: jakub Date: Mon Jun 8 16:48:11 2009 New Revision: 148282 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148282 Log: PR c++/40373 * call.c (check_dtor_name): Return false even if get_type_value (name) is error_mark_node. * g++.dg/template/dtor7.C: New test. Added: trunk/gcc/testsuite/g++.dg/template/dtor7.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 40373 Author: jakub Date: Mon Jun 8 16:49:17 2009 New Revision: 148283 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148283 Log: PR c++/40373 * call.c (check_dtor_name): Return false even if get_type_value (name) is error_mark_node. * g++.dg/template/dtor7.C: New test. Added: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/dtor7.C Modified: branches/gcc-4_4-branch/gcc/cp/ChangeLog branches/gcc-4_4-branch/gcc/cp/call.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
Subject: Bug 40373 Author: jakub Date: Mon Jun 8 17:02:17 2009 New Revision: 148284 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148284 Log: PR c++/40373 * call.c (check_dtor_name): Return false even if get_type_value (name) is error_mark_node. * g++.dg/template/dtor7.C: New test. Added: branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/dtor7.C Modified: branches/gcc-4_3-branch/gcc/cp/ChangeLog branches/gcc-4_3-branch/gcc/cp/call.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
Fixed for 4.3/4.4/4.5.