Hi, it seems like gcc has problems looking up the name of a super class, which is in a different namespace, when you odmit the namespace name. it works with icc,comeau and vc6. so i consider it as a bug in gcc. tested gcc versions are 3.3.2 and 3.4-20031112. 3.4 built with the default configure parameters. 3.3.2 is gentoo's versions (gcc (GCC) 3.3.2 20031022 (Gentoo Linux 3.3.2-r2, propolice)). a small program demonstrating the bug wil be appended. gcc output is: x.cc: In function `int main()': x.cc:12: error: 'class Y<0>' has no member named 'X' x.cc:12: error: `::x' undeclared (first use here)
Created attachment 5135 [details] file won't compile with gcc
I can confirm that this program ------------------------ namespace NS { template <int> struct X { int x;}; } template<int i> struct Y : NS::X<i> {}; int main() { Y<0> y; y.X<0>::x=1; } ------------------------------- indeed does not compile. I'm not quite sure that it should, though I seem to remember that we had another PR that was about something similar: the name of the base class is supposed to be injected into the namespace of the class, so this should indeed compile then. I think I even recall that some kind of DR was associated with this question. Nathan, do you remember? W.
Subject: Re: error in looking up template super classes in different namespace "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes: | I can confirm that this program | ------------------------ | namespace NS | { | template <int> struct X { int x;}; | } | | template<int i> struct Y : NS::X<i> {}; | | | int main() | { | Y<0> y; | y.X<0>::x=1; | } | ------------------------------- | indeed does not compile. I'm not quite sure that it should, though I The code is valid. .X<0>::x is explicit member access to the component "x" of the base subobject of type X<0>. -- Gaby
Confirmed by Nathan.
This is the same problem as PR 189 which was fixed yesterday. *** This bug has been marked as a duplicate of 189 ***