Bug 23976 - Beats me
Summary: Beats me
Status: RESOLVED DUPLICATE of bug 12970
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2005-09-20 08:21 UTC by Ivan Godard
Modified: 2006-01-13 15:42 UTC (History)
5 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Godard 2005-09-20 08:21:01 UTC
enum        endianness {littleEndian, hostEndianness, bigEndian};

template<typename T>
class       sBigEndian {
T           payload;

template<typename T>
class       asBigEndian : public sBigEndian<T> {
operator T() { return payload; }

gets you:

~/ootbc/members/src$ g++ foo.cc
foo.cc: In member function `asBigEndian<T>::operator T()':
foo.cc:13: error: `payload' undeclared (first use this function)
foo.cc:13: error: (Each undeclared identifier is reported only once for each
function it appears in.)
Comment 1 Andrew Pinski 2005-09-20 14:35:17 UTC
Read http://gcc.gnu.org/gcc-3.4/changes.html
In a template definition, unqualified names will no longer find members of a dependent base (as 
specified by [temp.dep]/3 in the C++ standard). 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 h ()
            m = 0; // error
            f ();  // error
            n = 0; // ::n is modified
            g ();  // ::g is called
You must make the names dependent, e.g. by prefixing them with this->. Here is the corrected 
definition of C<T>::h,

        template <typename T> void C<T>::h ()
          this->m = 0;
          this->f ();
          this->n = 0
          this->g ();
As an alternative solution (unfortunately not backwards compatible with GCC 3.3), you may use using 
declarations instead of this->:

        template <typename T> struct C : B<T> {
          using B<T>::m;
          using B<T>::f;
          using B<T>::n;
          using B<T>::g;
          void h ()
            m = 0;
            f ();
            n = 0;
            g ();
Comment 2 Ivan Godard 2005-09-20 20:35:50 UTC
Oh yeah - I've fallen into (and reported) that one before. How quickly we forget!

You know, a "perhaps you meant 'this->foo'?" in the diagnostic ould cut down on
the redundant reports you guys get :-)

Comment 3 Andrew Pinski 2006-01-13 15:42:01 UTC
Reopening to ...
Comment 4 Andrew Pinski 2006-01-13 15:42:23 UTC
To mark as a dup of bug 12970.

*** This bug has been marked as a duplicate of 12970 ***