Piotr Wyderski wrote:
Dodji Seketeli wrote:

That, and [dcl.typedef]/6 says:

     In a given scope, a typedef specifier shall not be used to redefine
     the name of any type declared in that scope to refer to a different
     type.

So, I tend to think that GCC is right here.
Right *where*? In case of the snippet provided by Ulf -- yes, obviously.
In my case there is no "that scope", i.e. I redefine the type "super" defined
in the *surrounding* scope, not in the very same, as Ulf did. It is exactly
the same situation as:

     { int i;
       float i;
     }

and:

     {int i;
         { float i;}
     }

GCC is right in both cases and, similarly, [dcl.typedef]/6 doesn't affect any 
of them at all, because, as you noted, there aren't any redeclarations in the 
same scope in any of the two snippets.

However, you should not forget about [basic.scope.class]/1. I will not post the 
wording again, but it means a name used in a class must mean the same thing in 
all uses and at the end of the class. [basic.lookup.unqual]/7 says

    A name used in the definition of a class X outside of a member function 
body or nested class definition [This refers to unqualified names following the 
class name; such a name may be used in the base-clause or may be used in the 
class definition.] ...

So, the name of the base class *is* used in the derived class and as such, must not be 
redefined throughout the whole class; in your example, "super" is violating 
that rule.

Note that no diagnostic is required for violation of this rule, so the compiler 
might just accept it. However, it is still invalid code and gcc is right to 
reject it.

Regards
    Jiří Paleček



Reply via email to