This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
gcc accept this illegal code, at least with 2.91, 2.95.3 and gcc version 3.4 20031120 (experimental) so this is not a regression struct foo { foo(); }; namespace bar { foo::foo() { } } Comeau catch it at foo::foo() definition error: overloaded function "foo::foo" cannot be defined in the current scope regards, Philippe Elie
Confirmed.
*** Bug 13700 has been marked as a duplicate of this bug. ***
I actually tripped over this in my own program just now. To explain why this is a particularly evil bug: in a header file x.h I had struct X { void f(); }; and in y.h: namespace NS { struct X { void f(); }; } Then in x.cc, I would #include "x.h" void X::f() {}; but in y.cc I made the error to include x.h instead of y.h: #include "x.h" namespace NS { void X::f() {}; } This compiled without error, as explained in this PR, but I later got linker errors about multiply defined symbols X::f, despite the fact that I defined these symbols in the second .cc file in a namespace. It is thus not only accepts-invalid, but also wrong-code. Needless to say that it was rather tedious to find the problem... I take the liberty to set the milestone tentatively to 3.5, in the hope that someone comes along with a fix to this problem until then. W.
*** Bug 17804 has been marked as a duplicate of this bug. ***
*** Bug 20711 has been marked as a duplicate of this bug. ***
Subject: Bug 13140 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2005-09-15 16:03:33 Modified files: libstdc++-v3 : ChangeLog libstdc++-v3/testsuite: testsuite_character.h gcc/cp : ChangeLog pt.c decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: class2.C gcc/testsuite/g++.dg/template: explicit8.C spec25.C Log message: PR c++/13140 * decl.c (check_class_member_definition_namespace): New function. (grokfndecl): Use it. (grokvardecl): Likewise. (grokdecl): Improve documentation. * pt.c (check_explicit_instantiation_namespace): New function. (register_specialization): Call check_specialization_namespace when replacing an implicitly instantiated function. (check_explicit_specialization): Ensure that DECL_CONTEXT is set correctly for namespace-scope specializations. (do_decl_instantiation): Use check_explicit_instantiation_namespace. (do_type_instantiation): Likewise. PR c++/13140 * g++.dg/parse/class2.C: New test. * g++.dg/template/explicit8.C: Likewise. * g++.dg/template/spec25.C: Likewise. * testsuite/testsuite_character.h: Specialize character<> templates in __gnu_cxx, not in __gnu_test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.3105&r2=1.3106 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/testsuite_character.h.diff?cvsroot=gcc&r1=1.6&r2=1.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4891&r2=1.4892 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.1034&r2=1.1035 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1426&r2=1.1427 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6066&r2=1.6067 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/class2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/explicit8.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec25.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed on mainline.
*** Bug 25748 has been marked as a duplicate of this bug. ***
*** Bug 26403 has been marked as a duplicate of this bug. ***
*** Bug 28130 has been marked as a duplicate of this bug. ***
on g++ v. 4.1.2 it is not fixed, But here I see "Fixed" with patches from 2005! code: namespace NS{//a namespace template<class T> class C//a template class inside a namespace { int f();//a member of C }; }//NS //here is the specialization template<> int NS:: C<int>::f(){return 0;}// !! I placed NS::
(In reply to comment #11) > on g++ v. 4.1.2 it is not fixed, But here I see "Fixed" with patches from 2005! Fixed meaning GCC is no longer accepting invalid code. Your code is invalid and should be rejected.