------- Comment #2 from reichelt at gcc dot gnu dot org 2008-03-29 17:11 ------- Here's a reduced testcase:
===================================== template<int> struct A { friend void foo(const A&) { __FUNCTION__; } }; inline void foo(const A<0>&) { __FUNCTION__; } void bar() { foo(A<0>()); } ===================================== The bug is fixed since GCC 4.2.0, as the code is correctly rejected: bug.cc: In instantiation of 'A<0>': bug.cc:17: instantiated from here bug.cc:4: error: redefinition of 'void foo(const A<0>&)' bug.cc:10: error: 'void foo(const A<0>&)' previously defined here On the 4.1 branch I still get an ICE, but after the above error message: bug.cc: In instantiation of 'A<0>': bug.cc:17: instantiated from here bug.cc:4: error: redefinition of 'void foo(const A<0>&)' bug.cc:10: error: 'void foo(const A<0>&)' previously defined here bug.cc:4: internal compiler error: tree check: expected var_decl or function_decl or type_decl or template_decl, have error_mark in tsubst_friend_function, at cp/pt.c:5352 Please submit a full bug report, [etc.] Since we already rejected the code with GCC 3.1 - 3.3.6 this is a regression. I don't think anybody will fix this minor problem on the 4.1 branch, though. Btw, the code was wrongly accepted by GCC 4.0.0 - 4.1.1. -- reichelt at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |reichelt at gcc dot gnu dot | |org Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Keywords| |error-recovery, ice-on- | |invalid-code Known to fail| |3.4.0 3.4.6 4.0.0 4.1.2 Known to work| |3.1 3.3.6 Last reconfirmed|0000-00-00 00:00:00 |2008-03-29 17:11:11 date| | Summary|ICE on overload of friend |[4.1 regression] ICE on |function definition inside a|overload of friend function |class |definition inside a class Target Milestone|--- |4.1.3 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35641