public inbox for
help / color / mirror / Atom feed
Subject: c++/10864: [diagnostic] Unreadable error message for "no match for 'A < B' operator" if A,B are templates
Date: Mon, 19 May 2003 15:16:00 -0000	[thread overview]
Message-ID: <> (raw)

>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
>Originator:     Wolfgang Bangerth
>Release:        unknown-1.0
present mainline
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 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> > >]':   instantiated from here 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.


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 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


 >,__default_alloc_template<true,0> >,allocator<basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> > > > > >::foo()':   instantiated from here 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> > > > >'

             reply	other threads:[~2003-05-19 15:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-19 15:16 bangerth [this message]
2003-05-19 21:17 Gabriel Dos Reis
2003-05-20  0:39 bangerth
2003-05-20  3:16 Giovanni Bajo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).