This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16709] templated public inheritance fails to compile.
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Jul 2004 13:26:02 -0000
- Subject: [Bug c++/16709] templated public inheritance fails to compile.
- References: <20040726065915.16709.alex.vanic@pgs.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-07-26 13:26 -------
Read <http://gcc.gnu.org/gcc-3.4/changes.html>:
n a template definition, unqualified names will no longer find members of a dependent base. For
example,
template <typename T> struct B {
int m;
int n;
int f ();
int g ();
};
int n;
int g ();
template <typename T> struct C : B<T> {
void g ()
{
m = 0; // error
f (); // error
n = 0; // ::n is modified
g (); // ::g is called
}
};
You must make the names dependent by prefixing them with this-> . Here is the corrected definition
of C<T>::g ,
template <typename T> void C<T>::g ()
{
this->m = 0;
this->f ();
this->n = 0
this->g ();
}
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16709