Possible scoping bug?
Martin von Loewis
martin@mira.isdn.cs.tu-berlin.de
Sun May 24 15:20:00 GMT 1998
> Changing line 9 to
>
> foo = (::foo*) 0;
>
> or
> foo = (struct foo*) 0;
>
> makes it work. Is this necessary?
Yes. This is explained in 3.3.7 [basic.scope.hiding]/2:
>> A class name (9.1) or enumeration name (7.2) can be hidden by the
>> name of an object, function, or enumerator declared in the same
>> scope. If a class or enumeration name and an object, function, or
>> enumerator are declared in the same scope (in any order) with the
>> same name, the class or enumeration name is hidden wherever the
>> object, function, or enumerator name is visible.
It later lists the two options you find: qualified lookup, and
elaborated type names.
Martin
More information about the Gcc-bugs
mailing list