This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15801] New: g++ fails to identify member variables in templates
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Jun 2004 19:12:42 -0000
- Subject: [Bug c++/15801] New: g++ fails to identify member variables in templates
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
g++ produces bad error for member variables. See how-to-repeat.
This error is triggered in kde 3.3 / kdeaddons.
Environment:
System: Linux hell.hell.gr 2.6.6 #35 Sat May 29 20:08:29 EEST 2004 i686 unknown unknown GNU/Linux
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.4.0/configure --enable-threads=posix --prefix=/usr --enable-languages=c,c++ --enable-shared --with-arch=pentium3 --with-cpu=pentium3 --enable-__cxa_atexit
How-To-Repeat:
Using this source:
template<class tA> struct A
{
int var1;
}
template<class tB> struct B : public A<tB>
{
void a()
{
int var2 = var1;
}
}
gives:
$ g++ a.c -c -o a.o
a.c: In member function `void B<tB>::a()':
a.c:10: error: `var1' undeclared (first use this function)
a.c:10: error: (Each undeclared identifier is reported only once for each function it appears in.)
------- Additional Comments From v13 at priest dot com 2004-06-03 19:12 -------
Fix:
This will make it work as expected:
void a()
{
- int var2 = var1;
+ int var2 = this->var1;
}
--
Summary: g++ fails to identify member variables in templates
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: v13 at priest dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15801