This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]