This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13140] declaration in global namespace, definition inside named or anon namespace


------- Additional Comments From bangerth at dealii dot org  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. 
   

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
      Known to fail|                            |2.95.3 3.2.3 3.3.3 3.4.0
                   |                            |3.5.0
   Target Milestone|---                         |3.5.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13140


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]