g++ 3.4 more restrictive than g++ 3.3 ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all

I'm just wondering about some differences between g++ 3.3 (3.3.6) and 
g++ 3.4 (3.4.5). Please have a look to this piece of code:

---8<---------------------------------------------
#include <iostream>

template <class ValueType> 
class A
{
protected:
  ValueType m_Field;
};

template <class ValueType>
class B : public A<ValueType>
{
  void TestParam(ValueType i)
  {
    m_Field = i;
  }
};

int main(void)
{
  return 0;
}

---8<---------------------------------------------

As far as I know the C++ language, syntax seems to be correct, and g++
3.3 does not output any error/warning (even with -Wall option). The
problem is that g++ 3.4 (and 4.0 btw) outputs the following:

For g++ 3.4:

Inherit.cpp: In member function `void
B<ValueType>::TestParam(ValueType)':
Inherit.cpp:16: error: `m_Field' undeclared (first use this function)
Inherit.cpp:16: error: (Each undeclared identifier is reported only once
for each function it appears in.)

For g++ 4.0:

Inherit.cpp: In member function 'void
B<ValueType>::TestParam(ValueType)':
Inherit.cpp:16: error: 'm_Field' was not declared in this scope


The very weird thing is that if I change the line 16 from
    m_Field = i;
to
    this->m_Field = i;

everything works without any kind of problem !!! So is this behaviour
normal ?

Best Regards,
Mathieu Fluhr




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux