This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/16709] templated public inheritance fails to compile.


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]