Bug 21043 - Compilation error when trying to call method of a class contain by grand-mother with a template mother and class
Summary: Compilation error when trying to call method of a class contain by grand-moth...
Status: RESOLVED DUPLICATE of bug 21012
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-15 11:20 UTC by maxime fiandino
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description maxime fiandino 2005-04-15 11:20:35 UTC
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);
}
Comment 1 maxime fiandino 2005-04-15 11:57:27 UTC
Hi, please note that for the same bahavior with the line, it's compiling:

((A*)(this))->m_.p(); 
Comment 2 Volker Reichelt 2005-04-15 12:59:58 UTC
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()
Comment 3 Andrew Pinski 2005-04-15 13:30:19 UTC
Reopening to mark as ...
Comment 4 Andrew Pinski 2005-04-15 13:30:42 UTC
a dup of bug 21012.

*** This bug has been marked as a duplicate of 21012 ***