c++/10864: [diagnostic] Unreadable error message for "no match for 'A < B' operator" if A,B are templates

[email protected]
Newsgroups gmane.comp.gcc.prs
Message-ID <[email protected]>
>Number:         10864
>Category:       c++
>Synopsis:       [diagnostic] Unreadable error message for "no match for 'A < B' operator" if A,B are templates
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 19 15:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang Bangerth
>Release:        unknown-1.0
>Organization:
>Environment:
present mainline
>Description:
This startled me, since I didn't see exactly what gcc
was complaining about -- I had code like
------------------------------
#include <string>
#include <vector>

template <class T> struct less {
  bool foo () { return T() < T(); }
};

template <typename,typename> class X {};
template struct less<X<std::vector<std::string>,
                       std::vector<std::string> > >;
-----------------------
(In fact it was even a little more complicated...). gcc
gives the following message (on mainline):

g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c y.cc
y.cc: In member function `bool less<T>::foo() [with T =
   X<std::vector<std::string, std::allocator<std::string> >,
   std::vector<std::string, std::allocator<std::string> > >]':
y.cc:10:   instantiated from here
y.cc:5: error: no match for `X<std::vector<std::string,
   std::allocator<std::string> >, std::vector<std::string,
   std::allocator<std::string> > > < X<std::vector<std::string,
   std::allocator<std::string> >, std::vector<std::string,
   std::allocator<std::string> > >' operator

Now, that's pretty hard to read. What it says is:
  no match for `A < B' operator
but the "<" is totally lost in all these template args.
I also always thought that the message was somehow
truncated, since usually in C++ there must be something
after the "operator" :-)

I think it would be nice if the message could be changed
to read like
  no match for operator< in expression `A < B'
That way it would be simpler to figure out which operator
exactly is missing.

W.


PS: As a heads up: this is what 2.95 produces on above 
code, which is way worse since it even states the
template args of the typedef expansion of std::string...

g/x> c++ -c y.cc
y.cc: In method `bool less<X<vector<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >,allocator<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> > > >,vector<basic_string<char,string_char_traits<char
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
 >,__default_alloc_template<true,0> >,allocator<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> > > > > >::foo()':
 y.cc:10:   instantiated from here
 y.cc:5: no match for `X<vector<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >,allocator<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> > > >,vector<basic_string<char,string_char_traits<char>,__d efault_alloc_template<true,0> >,allocator<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> > > > > < X<vector<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >,allocator<basic_string<char,string_char _traits<char>,__default_alloc_template<true,0> > > >,vector<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >,allocator<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> > > > >'
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.