public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: bangerth@dealii.org
To: gcc-gnats@gcc.gnu.org
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: <20030519151237.6498.qmail@sources.redhat.com> (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
>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> > > > >'


             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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20030519151237.6498.qmail@sources.redhat.com \
    --to=bangerth@dealii.org \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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).