This is the mail archive of the gcc@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]

Question w.r.t. inside class defined struct for C++ language lawer.


Hello,

I have one issue w.r.t. inside class defined struct with Sun's C++
compiler. I have reported them a bug and they claim their compiler is ok.
The problem is that the code is perfectly compilable by gcc3.4.0, icc8.0,
como4.3.3 and so I would like to know who is right and who is wrong and if
I should report gcc bug. The code looks like (simplified case):

       1
       2 #include <string>
       3
       4 class Foo
       5 {
       6 private:
       7         typedef std::string Identifier;
       8         //struct Operation;
       9         //friend struct Operation;
      10         struct Operation
      11         {
      12                 Identifier name;
      13         };
      14 };
      15
      16

Sun's CC complain about line 12:
"/tmp/kgardas/bug.cc", line 12: Error: Foo::Identifier is not accessible from Foo::Operation.
1 Error(s) detected.

Sun's engineer wrote me this:
``This is not a bug:
According to the 1998 C++ standard.  Struct members do not have any
special access to other members of their enclosing class.
You must explicitly grant permission.''

and he added to the test-case lines 8 and 9 (uncommented).

So my question is: are all compilers right? i.e. gcc, icc, como compiling
it and CC complaining about it? Or are gcc, icc, como right and Sun's CC
is wrong and also engineer from support is wrong? Or even are gcc, icc,
como wrong and Sun right? Should I report compilation of this wrong code
as a bug to gcc's bugzilla?

Thanks a lot,

Karel
--
Karel Gardas                  kgardas@objectsecurity.com
ObjectSecurity Ltd.           http://www.objectsecurity.com



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