[C++ PATCH for 3.1] Fix PR6716 regression (take 2)

Mark Mitchell mark@codesourcery.com
Wed Jun 26 09:50:00 GMT 2002

 I have messed up that a bit.  Originally, its size is zero (for this
> testcase included in my patch, other fail cases can have non-zero size)
> but eventually it's indistinguishable from other ordinary class.
> Consider the testcase.  There Z<int> contains Y<Z<int> >, which
> contains X<Z<int> >, which in turn contains Z<int>.

I had a hard time parsing your message (sorry!).

But I think what you're saying is this:

   If we, while instantiating a template, run into a field with the same
   type as a template that's being instantiated, we get into trouble.

   A simple case of this, which may not actually cause the problem, is:

   template <class T>
   struct S {
     S s;

   You can make this more complicated by burying the recursive use of
   S<T> down inside several data members.

   Our problem is that we create a circular data structure.

Obviously, we should issue an error when the user attempts to do this;
they've used an incomplete type in a situation where a complete type is

Beyond that, the question in my mind is what happens without templates.

The way that we handle:

  struct S { S s; };

is the same that we should handle the template case.

Do we still make a FIELD_DECL for s?  Do we give it type S, or is its
type error_mark_node?

Does that make sense?

Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com

More information about the Gcc-patches mailing list