On Thu, Apr 09, 2009 at 11:03:20AM -0700, Ian Lance Taylor wrote:
> Arthur Schwarz <aschwarz1...@verizon.net> writes:
> > 2: Stream errors are tortuous to decode to find the cause of
> >    error..Any thought to simplification?
> >
> >    In particular: 'stream << something_wrong;' can produce a
> >    multiline message with copious use of the templates used -
> >    but no simple statement as what the error is.
> 
> I completely agree that the C++ diagnostics need to be improved.  gcc
> mainline recently took a step forward with simplification of template
> error messages.  However, much more can be done.
> 
> One problem we face is that compiler developers tend to be too close to
> the problem.  It helps for users to give examples and to give specific
> suggestions for how the diagnostics could be improved.

The template message simplifications help, but in cases where there
are five or more overloads for some function, the front end needs to
be smarter.  It's pointless to spew out the 20 different overloads,
and would be better to try to hone in on the real cause of the error.

stream << something_wrong is a good example.  Perhaps something_wrong
is of struct or class type, and there are no overloads in scope to
print that class, and no conversions that will coerce that class into
something we can print.  It's pointless to print all of the operator<<
functions the compiler knows about!  Saying that there's no match
suffices.

In other cases the compiler could try to rank the possible close matches,
putting those that would match except for a const attribute at the top
(since in my experience const issues, like passing a temporary to
a function that has a non-const reference is common), then if a
& or a * would make the argument match an overload, put those in next.
Just print the top two possibilities and say if there are more.

Reply via email to