From mboxrd@z Thu Jan 1 00:00:00 1970 From: jorgen.sigvardsson@kau.se To: gcc-gnats@gcc.gnu.org Subject: c++/3024: class inheritance of template arguments fail Date: Fri, 01 Jun 2001 01:36:00 -0000 Message-id: <20010601082825.27680.qmail@sourceware.cygnus.com> X-SW-Source: 2001-06/msg00000.html List-Id: >Number: 3024 >Category: c++ >Synopsis: class inheritance of template arguments fail >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Fri Jun 01 01:36:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Jorgen Sigvardsson >Release: gcc 2.95.3 through gcc-3.0 snapshot 20010528 >Organization: >Environment: Reading specs from /usr/tmp/gcc/lib/gcc-lib/i386-unknown-freebsd4.3/3.0/specs Configured with: ./configure --prefix=/usr/tmp/gcc Thread model: single gcc version 3.0 20010528 (prerelease) >Description: Classes may not inherit from template argument. I use this with the Microsoft Visual C++ compiler frequently (ATL uses it heavily). I don't know if this is C++ by the book, or if it is a Microsoft extension. The code which fail for me looks like: template class Y : public T { // ... }; class X : public Y { }; This yields the error message: xxx.cpp: In instantiation of `Y': xxx.cpp:LL: instantiated from here xxx.cpp:LL: base class `X' has incomplete type >>From a "top down lexically scoped" point of view I fully agree with the compiler. >How-To-Repeat: Compile using g++ on the testcase given above. >Fix: I don't have a code fix, since I wouldn't understand the g++-code even if it jumped up and bit me in the ass. But I have some theories of how to make this work; Simply defer the instantiation of templated base classes if they may not be resolved on the fly. After the first pass of class X (in this case), then instantiate Y and apply the changes. (I have only taken a course in programming languages and compiler construction, so I'm probably totally out of my league here. ;) >Release-Note: >Audit-Trail: >Unformatted: