------- Additional Comments From dave at boost-consulting dot com  2005-03-26 
02:01 -------
Subject: Re:  Do not print default template arguments in error messages

"gdr at integrable-solutions dot net" <[EMAIL PROTECTED]> writes:

> ------- Additional Comments From gdr at integrable-solutions dot net  
> 2005-03-25 22:06 -------
> Subject: Re:  Do not print default template arguments in error messages
>
> "giovannibajo at libero dot it" <[EMAIL PROTECTED]> writes:
>
> | ------- Additional Comments From giovannibajo at libero dot it  2005-03-23 
> 02:44 -------
> | I'll try to do this. This is a simple testcase:
> | 
> | ---------------------------
> | template <class T, int N=0, int X=1>
> | struct A
> | {
> |    typedef typename T::x x;
> | };
> | void foo(void)
> | {
> |   A<void,0> a;
> | }
> | ---------------------------
> | test.cc: At global scope:
> | test.cc: In instantiation of 'A<void, 0, 1>':
> | test.cc:8:   instantiated from here
> | test.cc:4: error: 'void' is not a class, struct, or union type
> | 
> | Do we want the error message to show 'A<void, 0>' or 'A<void>'? In other 
> words, 
>
> Most of the time, we want to print what user wrote.  

That rule could be really bad in cases like:

     A<void, foo<bar>::value>

The actual identity of the 2nd argument is usually far more important
at the point where the error is reported than seeing the way the user
wrote it, and the deduction needed for the user to determine that
foo<bar>::value is actually 0, 1, or whatever can be arbitrarily
complicated.  The user may have to look through an arbitrary number of
template definitions in arbitrary locations, finding all
specializations and essentially doing instantiation by hand.  By
contrast, finding out how a template argument was written is trivial
because GCC gives you a nice backtrace where you will see each
template in the instantiation chain being supplied with arguments.

Please, I'm begging you not to go down this road.  GCC is one of the
only compilers that gets it right today (VC8 will follow), and all the
ones that try to follow the "show how it was written" rule often give
errors that are, for all practical purposes, unusable.  If you make
GCC work like the others, it will be a leap backwards and a terrible
disservice to users.

If you choose to show an argument that happens to match the default
but was in fact supplied explicitly, I have no real objection.  Just
show it in its simplified normal form and do not try to show "what was
written."

If you never really meant to go in the direction I fear, I just ask
that you try find a way to describe what you want that can't be
misinterpreted the way I did.  Someone might go off and do the wrong
thing anyway unless it is expressed clearly.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14912

Reply via email to