g++ -v Reading specs from /.../Open-Sources/gcc/gcc-3.4.3/linux-x86/bin/../lib/gcc/i686-pc-linux-gnu/3.4.3/specs Configured with: /.../Open-Sources/gcc/gcc-3.4.3/src/configure --prefix=/.../Open-Sources/gcc/gcc-3.4.3/linux-x86 Thread model: posix gcc version 3.4.3 When i try to compile this code there is an error but it's compiling fine with "comeau online": main.cc: In constructor `C<T>::C()': main.cc:10: error: object missing in reference to `A::m_' main.cc:25: error: from this location But it's working fine with this->m_.p(); insteed of A::m_.p(); Following main.ii # 1 "main.cc" # 1 "<built-in>" # 1 "<command line>" # 1 "main.cc" struct X { void p() { ; } }; struct A{ X m_; }; template<typename T> struct B : public A { B():A(){Y=0;} int Y; }; template<typename T> struct C : public B<T> { C():B<T>() { A::m_.p(); Z=0; } T Z; }; int main() { C<int> test; return(1); }
Hi, please note that for the same bahavior with the line, it's compiling: ((A*)(this))->m_.p();
Not a bug. This has to do with two-stage name-lookup, see last bullet in http://gcc.gnu.org/bugs.html#new34 and http://gcc.gnu.org/gcc-3.4/changes.html You could use this->m_.p(), this->A::m_.p(), B<T>::A::m_.p()
Reopening to mark as ...
a dup of bug 21012. *** This bug has been marked as a duplicate of 21012 ***