This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++ rejects legal?
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: Giovanni Bajo <giovannibajo at libero dot it>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 4 Nov 2004 14:54:17 +0100 (CET)
- Subject: Re: g++ rejects legal?
On Thu, 4 Nov 2004, Giovanni Bajo wrote:
> Richard Guenther wrote:
>
> > Hi!
> > There must be some weird C++ rules again. Consider:
>
> Recursive instantiations.
>
> You are trying to instantiate ComponentView<>, which, for some reason, requires
> Array<> to be complete. Completing Array<> requires instantiating the prototype
> of Array<>::comp() which, in turn, asks for ComponentView<> instantiation.
>
> This does not happen with AltComponentView<> since its instantiation is not
> required to complete Array<> so there is no loop.
Ah, I see. That makes sense. Can this be detected (I'm sure it is, or we
would be endlessly looping(?)) and the diagnostic improved? Like
notype.cpp: In instantiation of 'Array<1, double, Brick>':
notype.cpp:33: instantiated from `ComponentView<Loc<1>, foo()::Array_t>'
notype.cpp:78: instantiated from here
notype.cpp:71: error: trying to recursively instatiate
`ComponentView<Loc<1>, foo()::Array_t>' through 'Type_t' in
'struct ComponentView<Loc<1>, foo()::Array_t>'
or the like? Would have saved me half a day ;)
Thanks,
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/