public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
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	[thread overview]
Message-ID: <20010601082825.27680.qmail@sourceware.cygnus.com> (raw)

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


             reply	other threads:[~2001-06-01  1:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-01  1:36 jorgen.sigvardsson [this message]
2001-06-01  3:26 Artem Khodush
2001-06-01  4:36 Jörgen Sigvardsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010601082825.27680.qmail@sourceware.cygnus.com \
    --to=jorgen.sigvardsson@kau.se \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).