This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/9558: subclass cannot find parent members without explicit "this->" in some cases
- From: ryan at epicgames dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 3 Feb 2003 23:30:23 -0000
- Subject: c++/9558: subclass cannot find parent members without explicit "this->" in some cases
- Reply-to: ryan at epicgames dot com
>Number: 9558
>Category: c++
>Synopsis: subclass cannot find parent members without explicit "this->" in some cases
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 03 23:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: ryan@epicgames.com
>Release: unknown-1.0
>Organization:
>Environment:
>Description:
As this is a 23-line test case with no #includes, it'll speak best for itself, but I'll comment afterwards.
...here's the preprocessed source:
# 1 "x.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "x.cpp"
template< class T > class A
{
public:
A() {}
int important_value;
};
template< class T > class B : public A<T>
{
public:
B() : A<T>()
{
this->important_value = 10;
important_value = 10;
}
};
int main(void)
{
B<int> x();
return(0);
}
...and here is the -v -save-temps output:
[icculus@wickedsick ~]$ gcc -v -save-temps -o x ./x.cpp
Reading specs from /usr/local/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.4/specs
Configured with: ../gcc/configure --prefix=/usr/local/gcc-cvs
Thread model: posix
gcc version 3.4 20030203 (experimental)
/usr/local/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.4/cc1plus -E -D__GNUG__=3 -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=4 -D__GNUC_PATCHLEVEL__=0 -D_GNU_SOURCE ./x.cpp x.ii
ignoring nonexistent directory "/usr/local/gcc-cvs/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc-cvs/include/c++/3.4
/usr/local/gcc-cvs/include/c++/3.4/i686-pc-linux-gnu
/usr/local/gcc-cvs/include/c++/3.4/backward
/usr/local/include
/usr/local/gcc-cvs/include
/usr/local/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.4/include
/usr/include
End of search list.
/usr/local/gcc-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.4/cc1plus -fpreprocessed x.ii -quiet -dumpbase x.cpp -auxbase x -version -o x.s
GNU C++ version 3.4 20030203 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 2.95.3 20010315 (release).
x.cpp: In constructor `B<T>::B()':
x.cpp:15: error: `important_value' has not been declared
The important part is B::B()'s assignments to "important_value". This gives an incorrect error stating that the member is not declared unless specifically prepended with "this->".
More notes: if "A" is not a template, or it uses a explicit type ("A<int>" instead of, "A<T>"), this error goes away, too. I assume this is just a minor detail in the new recursive-descent parser, but I'll leave real analysis to the experts. :)
Thanks!
--ryan.
>How-To-Repeat:
Compile the example file. Result is consistent in CVS from about 12 hours ago (february 2nd, 2003).
>Fix:
I have none at this time.
>Release-Note:
>Audit-Trail:
>Unformatted: