c++/3024: class inheritance of template arguments fail
jorgen.sigvardsson@kau.se
jorgen.sigvardsson@kau.se
Fri Jun 1 01:36:00 GMT 2001
>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 <typename T>
class Y : public T
{
// ...
};
class X : public Y<X>
{
};
This yields the error message:
xxx.cpp: In instantiation of `Y<X>':
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<X> 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:
More information about the Gcc-bugs
mailing list