Bug#249691: gcc-3.4: false compiler error (templated base, templated child, private member)
> template <class T>
> class A
> {
> protected:
> int f;
> };
>
> template <class T>
> class B: public A<T>
> {
> public:
> B()
> {
> f = 1; // line 14
> }
> };
>
> gcc-3.3 has no problem with this, but gcc-3.4 complains as follows:
>
> a.cc: In constructor `B<T>::B()':
> a.cc:14: error: `f' undeclared (first use this function)
> a.cc:14: error: (Each undeclared identifier is reported only once for each function it appears in.)
This is an intended consequence of the new 3.4 C++ parser. From
http://gcc.gnu.org/gcc-3.4/changes.html
"In a template definition, unqualified names will no longer find
members of a dependent base"
You need to refer to "this->f" rather than the unqualified "f".
--
Philip Martin
Reply to: