Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 13140
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: phil.el@wanadoo.fr
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 13140 depends on: Show dependency tree
Show dependency graph
Bug 13140 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2005-07-01 04:35 Opened: 2003-11-20 19:49
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

------- Comment #1 From Wolfgang Bangerth 2003-11-20 20:44 -------
Confirmed.

------- Comment #2 From Andrew Pinski 2004-02-03 08:16 -------
*** Bug 13700 has been marked as a duplicate of this bug. ***

------- Comment #3 From Wolfgang Bangerth 2004-03-23 20:15 -------
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. 
   

------- Comment #4 From Andrew Pinski 2004-10-03 14:57 -------
*** Bug 17804 has been marked as a duplicate of this bug. ***

------- Comment #5 From Andrew Pinski 2005-04-01 13:08 -------
*** Bug 20711 has been marked as a duplicate of this bug. ***

------- Comment #6 From CVS Commits 2005-09-15 16:03 -------
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


------- Comment #7 From Volker Reichelt 2005-09-16 18:16 -------
Fixed on mainline.

------- Comment #8 From Andrew Pinski 2006-01-11 14:16 -------
*** Bug 25748 has been marked as a duplicate of this bug. ***

------- Comment #9 From Andrew Pinski 2006-02-21 21:10 -------
*** Bug 26403 has been marked as a duplicate of this bug. ***

------- Comment #10 From Andrew Pinski 2006-06-21 22:58 -------
*** Bug 28130 has been marked as a duplicate of this bug. ***

------- Comment #11 From Becheru Petru 2006-06-21 23:11 -------
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::

------- Comment #12 From Andrew Pinski 2006-06-21 23:17 -------
(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.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug