Concept-check bug ?

Jonathan Wakely
Fri Jun 17 12:53:00 GMT 2005

On Fri, Jun 17, 2005 at 02:21:00PM +0200, Gabriel Dos Reis wrote:

> Jonathan Wakely <> writes:
> | Hi y'all,
> | 
> |     #include <vector>
> | 
> |     struct A {
> |         std::vector<A> v;
> |     };
> | 
> | This produces concept-check errors because A is incomplete at the point
> | of declaring v.
> | 
> | Is this code really illegal, or just a flaw in the concept-checks ?
> I think it is invalid (how can T be CopyConstructible if it is not
> complete?), which annoys me more often than not.  I always 
> forget to raise the issue with LWG.  It is ridiculous.

Yes, it seems obvious it's invalid now - but only to a language pedant
like me, most users would probably expect it to be OK.

This variation is slightly more surprising to me

     template <class T>
     struct A {
         std::vector<A> v;

since by the time you actually instantiate a specialisation, the type
_is_ complete ... but I guess the concept-checking is done before the
specialisation is complete.

I should probably take that question to the C++ panel, rather than here,
since it seems the concept-checks are alright so it's not a GCC issue.

Thanks, Gaby.


"When angry, count four; when very angry, swear."
	- Mark Twain

More information about the Libstdc++ mailing list