I get an ICE with the attached pre-processed code. I get it with g++ 3.4.3, as well as 4.0.0-20041111. With no particular command line option (-O2 or nothing produces it).
Created attachment 7523 [details] preprocessed source code
Hmm, this looks related to PR 17829 (but that was fixed and this is still broken).
Reduced testcase: ===================================== struct A { static void foo(A); }; struct B { friend void foo(B); }; template<typename T> struct C : T { C() { foo(T()); } }; C<A> c; =====================================
I see segfault in perform_or_defer_access_check too, on: template <class T1, class T2> struct P { T1 t1; T2 t2; P () : t1(), t2() { } template <class U1, class U2> P (const P<U1, U2> &x) : t1(x.t1), t2(x.t2) { } }; template <typename T> inline void f (T &x, T &y) { const T t = x; x = y; y = t; } template <class T> struct A { static void f (T &x, T &y) { T t = x; x = y; y = t; } }; template <class T> struct B : public A<T> { static void g (T *x, T *y) { f (*y, *x); } }; int foo () { P<long, long> *a, *b; B<P<long, long> >::g (a, b); } Works with GCC 3.3, segfaults with 3.4.3 and 4.0 current.
The examples from comment #3 and comment #4 can both be reduced to ===================================== void foo(int); struct A { static void foo(A); }; template<typename T> struct B : T { B() { foo(T()); } }; B<A> b; ===================================== I'm not sure whether this is valid or not - icc for example rejects the code in strict mode.
Mark, the ICE on mainline appears with your patch http://gcc.gnu.org/ml/gcc-cvs/2004-09/msg01274.html
: Search converges between 2004-09-27-014001-trunk (#563) and 2004-09-27-161002-trunk (#564). : Search converges between 2004-09-27-004002-3.4 (#82) and 2004-09-28-004001-3.4 (#83).
Subject: Bug 18436 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-11-12 21:47:13 Modified files: gcc/cp : ChangeLog decl.c decl2.c parser.c pt.c tree.c gcc/testsuite : ChangeLog gcc/testsuite/g++.dg/ext: vla1.C vlm1.C gcc/testsuite/g++.dg/template: crash2.C Added files: gcc/testsuite/g++.dg/parse: cond1.C gcc/testsuite/g++.dg/template: array9.C call3.C ptrmem11.C Log message: PR c++/18389 * decl.c (start_decl): Make sure to set *pop_scope_p. Return error_mark_node to indicate errors. PR c++/18429 * parser.c (cp_parser_direct_declarator): Disallow non-constant array bounds when not inside a function. PR c++/18436 * pt.c (tsubst_copy_and_build): Do not do Koenig lookup when an unqualified name resolves to a member function. PR c++/18407 * pt.c (tsubst_copy_and_build): Handle qualified names used from a derived class correctly. * decl2.c (import_export_decl): Fix typo in comment. * tree.c (pod_type_p): Likewise. PR c++/18389 * g++.dg/parse/cond1.C: New test. PR c++/18429 * g++.dg/template/array9.C: New test. * g++.dg/ext/vla1.C: Adjust error messages. * g++.dg/ext/vlm1.C: Likewise. * g++.dg/template/crash2.C: Likewise. PR c++/18436 * g++.dg/template/call3.C: New test. PR c++/18407 * g++.dg/template/ptrmem11.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4480&r2=1.4481 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1326&r2=1.1327 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.756&r2=1.757 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.278&r2=1.279 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.944&r2=1.945 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.418&r2=1.419 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4588&r2=1.4589 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/vla1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/vlm1.C.diff?cvsroot=gcc&r1=1.2&r2=1.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/cond1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/array9.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/call3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem11.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash2.C.diff?cvsroot=gcc&r1=1.2&r2=1.3
Subject: Bug 18436 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-11-12 21:57:31 Modified files: gcc/cp : decl.c pt.c ChangeLog gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: cond1.C gcc/testsuite/g++.dg/template: call3.C ptrmem11.C Log message: PR c++/18389 * decl.c (start_decl): Make sure to set *pop_scope_p. Return error_mark_node to indicate errors. PR c++/18436 * pt.c (tsubst_copy_and_build): Do not do Koenig lookup when an unqualified name resolves to a member function. PR c++/18407 * pt.c (tsubst_copy_and_build): Handle qualified names used from a derived class correctly. * decl2.c (import_export_decl): Fix typo in comment. * tree.c (pod_type_p): Likewise. PR c++/18389 * g++.dg/parse/cond1.C: New test. PR c++/18436 * g++.dg/template/call3.C: New test. PR c++/18407 * g++.dg/template/ptrmem11.C: New test. Patches: 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.27&r2=1.1174.2.28 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.45&r2=1.816.2.46 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.178&r2=1.3892.2.179 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.308&r2=1.3389.2.309 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/cond1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/call3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem11.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.4.4.