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]

Re: problem with: namespace N { class N {...}; }




Hi,

To me this looks related to another long standing bug which is in all versions
of 2.95, including egcs-20000501.

I have some ideas on how to fix it, but I prefer to consult with the author.
Can anybody help me figure out who rewrote the involved code? 

Thanks,
-Raymond


----------------------------------------------------------------------
class A {
  class B;
  class C {
    class D;
  };
};

class A::C::D {
  B* b;         // illegitimately rejected by 2.95.*, ok in older versions
};
----------------------------------------------------------------------



> > I have this code (and I hope it is correct C++ code):
> 
> Thanks for your bug report. I've put it into GNATS.
> 
> Regards,
> Martin
> 
> 
> 
> > Dear GCC developers,
> 
> > I have this code (and I hope it is correct C++ code):
> 
> > class A {};
> > namespace N
> > {
> >   class B { friend A operator>>(A,B); };   // -B-
> >   class N { friend A operator>>(A,N); };   // -N-
> > }  
> > A N::operator>>(A, N::B) { return A(); }   // -B-
> > A N::operator>>(A, N::N) { return A(); }   // -N-
> > 
> > $ g++ -c a1.c
> > a1.c:7: type specifier omitted for parameter
> > a1.c:7: `N::operator >>(A)' should have been declared inside `N'
> > a1.c:7: `N::operator >>(A)' must take exactly two arguments
> > 
> > If you remove lines marked with -B- or with -N- then gcc will compile the
> > code.
> > 
> > The same problem exists with this code (try to remove marked lines):
> > 
> > class A {};
> > namespace N
> > {
> >   class B {};  void f(B); // -B-
> >   class N {};  void f(N); // -N-
> > }  
> > void N::f(N::B) {}   // -B-
> > void N::f(N::N) {}   // -N-
> > 
> > $ g++ -c a2.c
> > a2.c:7: `B' is not a member of type `N::N'
> > a2.c:7: variable or field `f' declared void
> > a2.c:7: `int N::f' redeclared as different kind of symbol
> > a2.c:5: previous declaration of `void N::f(N::N)'
> > a2.c:7: syntax error before `{'
> > 
> > I use gcc version 2.95.2 19991024 (release).
> > 
> > With best wishes,
> > Alexander Zvyagin.

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