This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/23735] New: Visibility of template base class members
- From: "dreiners at iastate dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Sep 2005 14:56:47 -0000
- Subject: [Bug c++/23735] New: Visibility of template base class members
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hi everybody,
I'm running into some unexpected behavior with template base classes:
template <int Q>
struct A
{
int a;
};
template <int Q>
struct B : public A<Q>
{
B(void);
};
template <int Q>
B<Q>::B(void)
{
a = 0; // This doesn't work
A<Q>::a = 0; // This does ...
this->a = 0; // and so does this
}
gcc 3.4.2 says:
> test.cpp: In constructor `B<Q>::B()':
> test.cpp:23: error: `a' undeclared (first use this function)
> test.cpp:23: error: (Each undeclared identifier is reported only once
> for each function it appears in.)
gcc 4.1.0 says:
> test.cpp: In constructor 'B<Q>::B()':
> test.cpp:22: error: 'a' was not declared in this scope
It works fine with VS.Net and Intel compilers.
This was tested with the following systems:
gcc 3:
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/
usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-
system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-
awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
gcc 4:
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/opt/gcc-4.0 --with-gcc-version-
trigger=/opt/gcc-4.0/gcc/gcc/version.c --enable-languages=c,c++
Thread model: posix
gcc version 4.1.0 20050727 (experimental)
Thanks for your help!
Dirk
--
Summary: Visibility of template base class members
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dreiners at iastate dot edu
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23735