>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> > > > >'
The following reply was made to PR c++/10864; it has been noted by GNATS. From: Gabriel Dos Reis <gdr@integrable-solutions.net> To: bangerth@dealii.org Cc: gcc-gnats@gcc.gnu.org Subject: Re: c++/10864: [diagnostic] Unreadable error message for "no match for 'A < B' operator" if A,B are templates Date: 19 May 2003 23:08:18 +0200 bangerth@dealii.org writes: | 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 fully agree. I must confess that I have never been sympathetic to the way we handle messages saying "no match for bubble[tangle] operator". Sometime, they just look very strange to read. | 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. I think that is a very good suggestion. -- Gaby
Synopsis: [diagnostic] Unreadable error message for "no match for 'A < B' operator" if A,B are templates Responsible-Changed-From-To: unassigned->gdr Responsible-Changed-By: bangerth Responsible-Changed-When: Tue May 20 00:39:07 2003 Responsible-Changed-Why: Gaby wanted all diagnostic related bug reports, and ... State-Changed-From-To: open->analyzed State-Changed-By: bangerth State-Changed-When: Tue May 20 00:39:07 2003 State-Changed-Why: ... has already agreed to this particular one. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10864
The following reply was made to PR c++/10864; it has been noted by GNATS. From: "Giovanni Bajo" <giovannibajo@libero.it> To: <gcc-prs@gcc.gnu.org>, <gdr@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org>, <bangerth@dealii.org> Cc: Subject: Re: c++/10864: [diagnostic] Unreadable error message for "no match for 'A < B' operator" if A,B are templates Date: Tue, 20 May 2003 05:06:51 +0200 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10864 For reference: GCC with StlFilt: pr10864.cpp: In member function `bool less<X<vector<string>, vector<string> > >::foo()': pr10864.cpp:10: instantiated from here pr10864.cpp:5: error: no match for `X<vector<string>, vector<string> > < X<vector<string>, vector<string> >' operator Comeau: "pr10864.cpp", line 5: error: no operator "<" matches these operands operand types are: 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>>> bool foo () { return T() < T(); } ^ detected during instantiation of "bool less<T>::foo() [with T=X<std::vector<std::string, std::allocator<std::string>>, std::vector<std::string, std::allocator<std::string>>>]" at line 10 Comeau with StlFilt (yes, it screws indentation a little): pr10864.cpp(5): error: no operator "<" matches these operands operand types are: X<vector<string>, vector<string>> < X<vector<string>, vector<string>> bool foo () { return T() < T(); } ^ detected during instantiation of "bool less<X<vector<string>, vector<string>>>::foo()" at line 10 Giovanni Bajo