This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Using incomplete types to instantiate STL-Templates?
- From: "Christian Ehrhardt" <ehrhardt at mathematik dot uni-ulm dot de>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 30 Apr 2003 17:42:56 +0200
- Subject: Using incomplete types to instantiate STL-Templates?
Hi,
the following piece of code fails with --enable-concept-checks
(this is PR 10505):
------- cut ----------
#include <list>
class Foo
{
public:
int x;
std::list<Foo> children;
};
------- cut ----------
This happens because instantiation of std::list<Foo> will try to
declare a variable of type Foo. This fails because Foo is incomplete
at the point of instantiation. Basically the question is:
Is this construct legal?
I could only find two things that might be relevant to this in the
standard:
* Generally it is allowed to instatiate a template with an incomplete type.
However, the program may be ill-formed depending on what the template does
with this incomplete type (I can dig up the section numbers if this is
necessary).
* For the standard library there is this restriction in 17.3.4.6[2]:
In particular, the effects are undefined in the following cases:
[ ... ]
-- if an incomplete type (3.9) is used as a template argument
when instantiating a template component.
I'm not sure if the second point is really relevant. Mostly because
I'm not entirely sure what a template component is supposed to be.
regards Christian
--
THAT'S ALL FOLKS!