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]
Other format: [Raw text]

RE: c++/10273: g++ fails to compile sort() with a template operatorthat takes a pointer


> Is it unreasonable to ask for a better error message in this case ?
> Or perhaps better checking of templates ?  (This would probably cause
> a more accurate error message to be output.)

I guess in this case, the error message is as clear as it can be: the 
declaration of the template is legal (you parameterize it on a value, not 
on a type as you had expected) so there is nothing the compiler could have 
told you there. Then you tried to use the template with a type instead of 
the required value and the compiler told you
  x.cc: In function `void std::doit()':
  x.cc:31: type/value mismatch at argument 1 in template parameter list for `
   template<std::ClassName*<anonymous> > struct std::xLess'
  x.cc:31:   expected a constant of type `std::ClassName*', got `std::ClassName*'

I think the message says it quite clearly: first the type/value mismatch, 
then in addition that it expected a value and got a type. What more do you 
want?

Regards
  Wolfgang

PS: General experience from such mishaps is a) don't use existing names 
for template parameters (you re-used ClassName, which is an existing class 
name, as the name of the template parameter), and b) use "typename" 
instead of "class" in template argument lists. Both measures would have 
yielded the syntax error that you expected at the point of declaration of 
the template.

-------------------------------------------------------------------------
Wolfgang Bangerth             email:            bangerth at ticam dot utexas dot edu
                              www: http://www.ticam.utexas.edu/~bangerth/



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