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++/15075] "using namespace" fails in part


------- Additional Comments From bangerth at dealii dot org  2004-04-22 17:50 -------
Actually, I believe that gcc is right rejecting the code. This is how it 
fails: 
----------- 
namespace Test { 
  class A { 
    private: 
      class B {}; 
      friend void fails(B const &); 
  }; 
} 
 
using namespace Test; 
 
void fails(A::B const &) {} 
-------------- 
 
So we agree that the friend declaration injects the name into namespace Test. 
Which we then have again in the using thing. And then comes the definition 
of fail, but I believe the compiler is correct in assuming that this  
definition has to be in the global namespace -- the using directive only 
gets active once we _look up_ names, not when we declare/define new names. 
So clearly the definition of fails() does not define the predeclared/injected 
Test::fails function, and the compiler is correct in rejecting it due to 
an access violation: 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
x.cc: In function `void fails(const Test::A::B&)': 
x.cc:4: error: `class Test::A::B' is private 
x.cc:11: error: within this context 
 
Giovanni, what was your reasoning that differed from this here? 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|accepts-invalid             |


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


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