namespace lookup
Andrew Pinski
pinskia@gmail.com
Thu May 24 21:52:00 GMT 2007
On 5/24/07, Ching, Jimen (US SSA) <jimen.ching@baesystems.com> wrote:
> Hi,
>
> I have the following code:
>
> namespace X
> {
> namespace Y
> {
> namespace Z
> {
> struct A { typedef int int_t; };
> struct Z { typedef int int_t; };
> }
> }
> }
>
> using namespace X::Y::Z;
>
> int
> main()
> {
> Z::A::int_t i = 0;
> Z::Z::int_t j = 0;
> return i == j;
> }
> Why did g++ look for struct A in struct Z instead of namespace Z?
> It looked for struct Z in namespace Z.
Actually it did not look for struct Z in namespace Z. It found the
constructor Z in struct Z. Note this is a bug that it found the
constructor as the type, see
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11764 .
Thanks,
Andrew Pinski
More information about the Gcc
mailing list