This is the mail archive of the gcc-bugs@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]

Re: egcs 1.0.1 bug


Adam P Jenkins writes:

> Part of the problem is that the warning message g++ gives when it
> encounters a friend declaration in a template class is unclear.
> Here's an example

I have already submitted a patch that will produce a better error
message.  I hope it appears in the next snapshot.

> Notice what it says, about adding <> after the function name.  If I
> just change the friend declaration to 
>      friend A<T> foo<> (A<T> a);
> I get a syntax error like I'd expect.

Why would you expect that?  If there were a declaration of a template
function foo before that, this would be absolutely valid.

> I figured that
> regardless of whether it was a syntax error, the compiler shouldn't
> crash, so I sent a bug report.

Mark Mitchell has submitted patches that may fix this problem.

> If I add the declarations that Alexandre suggested:
> before the class declaration, I still get the same warning, and link
> error.

That's because you must also add the angle brackets in the friend
declaration.

> Finally, if I change the call to foo, in main, to foo<int>(a);

Because you did not fix the problem the warning message referred to.
The warning message pointed to the declaration line; it was that line
that had to be fixed.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil


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