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]

Re: [C++] Possible GCC bug


On Fri, Nov 16, 2012 at 7:15 AM, Piotr Wyderski
<piotr.wyderski@gmail.com> 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;}
>     }
>

The scope is obvious:

 class X : public super::X

 {
   typedef super::X super;
    };

> 3.3.6/1: ... A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the
> completed scope of S. No diagnostic is required for a violation of
> this rule. ...

The N here is supper, the class S here is X.  supper at the context of
the declaration of supper means the out scope supper and then its
meaning has changed by the end of the completed scope of X.  So GCC is
correct in erroring If you go by the literal use of 3.3.6/1.  The
other compilers are correct only because no diagnostic is required but
this is still invalid code.

Thanks,
Andrew Pinski


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