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] New: templated public inheritance fails to compile.


The following highly simplified example code fails to compile under gcc 3.4.1
(or 3.4.0, for that matter). It produces the error message ....

test.C: In constructor `Q<T>::Q(const T&)':
test.C:9: error: `x' undeclared (first use this function)
test.C:9: error: (Each undeclared identifier is reported only once for each
function it appears in.)

The code will build under gcc 3.3.3 and earlier. It also happily builds under
the proprietry compiliers (and hardware) of Sun, IBM and SGI. 

The system(s) are vanilla pc's with pentium processors and running redhat 9. It
is also built for amd64 running Fedora core 2 (kernal 2.6.7), the behaviour is
identical.

The only flag specified for the configuration/build of gcc 3.4.1 was
--enable-threads=posix.

template < class T > class P {
   public:
      T x ;
} ;

template <class T> class Q : public P<T> {
   public:
      Q( const T & y ) {
         x = y ;
      }
} ;

int main( int argc, char *argv[] ) {
   Q<int> q( 1 ) ;
   return 0 ;
}

-- 
           Summary: templated public inheritance fails to compile.
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alex dot vanic at pgs dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: redhat 9 on Intel Pentium, gcc 3.4.1
  GCC host triplet: redhat 9 on Intel Pentium, gcc 3.4.1
GCC target triplet: redhat 9 on Intel Pentium, gcc 3.4.1


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]