public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49152] New: Unhelpful diagnostic for iterator dereference
@ 2011-05-24 21:43 redi at gcc dot gnu.org
  2011-09-21 13:56 ` [Bug c++/49152] " giecrilj at stegny dot 2a.pl
                   ` (48 more replies)
  0 siblings, 49 replies; 50+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-24 21:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49152

           Summary: Unhelpful diagnostic for iterator dereference
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org


This code, based on what happens in std::find():

#include <vector>

struct X { };
struct Y { } val;

std::vector<X>::iterator first;

bool b = *first == val;

produces this output:

fail.cc:8:20: error: no match for 'operator==' in
'first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with
_Iterator = X*, _Container = std::vector<X>,
__gnu_cxx::__normal_iterator<_Iterator, _Container>::reference = X&]() == val'

or with -fno-pretty-templates

fail.cc:8:20: error: no match for 'operator==' in
'first.__gnu_cxx::__normal_iterator<X*, std::vector<X, std::allocator<X> >
>::operator*() == val'


I have a few problems with the diagnostic, the main ones are

1) Why is the "()" after the "[with ...]" template argument list in the
-fpretty-templates version?

2) "first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*" is an
abomination, "*first" would be far more helpful

3) after all that verbosity about *first, there's no clue what type val is.


To be helpful it should either show something resembling the original source:

   *first == val;

or it should show the types involved:

   no match for operator== with operands X& and Y&

or it should show both, like clang does:

error: invalid operands to binary expression ('X' and 'struct Y')
bool b = *first == val;
         ~~~~~~ ^  ~~~

but what we actually have doesn't manage to resemble the original source or
show the types involved


^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2015-06-22 14:25 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-24 21:43 [Bug c++/49152] New: Unhelpful diagnostic for iterator dereference redi at gcc dot gnu.org
2011-09-21 13:56 ` [Bug c++/49152] " giecrilj at stegny dot 2a.pl
2011-09-21 21:03 ` giecrilj at stegny dot 2a.pl
2011-09-21 21:51 ` redi at gcc dot gnu.org
2011-09-21 23:31 ` redi at gcc dot gnu.org
2011-09-21 23:31 ` manu at gcc dot gnu.org
2011-09-21 23:57 ` redi at gcc dot gnu.org
2011-09-22  0:16 ` manu at gcc dot gnu.org
2011-09-28  0:11 ` giecrilj at stegny dot 2a.pl
2012-03-21 13:25 ` manu at gcc dot gnu.org
2012-03-21 13:30 ` manu at gcc dot gnu.org
2012-03-22  1:53 ` paolo.carlini at oracle dot com
2012-03-22 10:41 ` paolo.carlini at oracle dot com
2012-03-22 11:08 ` redi at gcc dot gnu.org
2012-03-22 11:22 ` redi at gcc dot gnu.org
2012-03-22 11:38 ` manu at gcc dot gnu.org
2012-03-22 12:04 ` redi at gcc dot gnu.org
2012-03-22 13:01 ` manu at gcc dot gnu.org
2012-03-22 14:27 ` suckfish at ihug dot co.nz
2012-03-22 14:34 ` redi at gcc dot gnu.org
2012-03-23  8:20 ` suckfish at ihug dot co.nz
2012-03-24 16:59 ` manu at gcc dot gnu.org
2012-03-31  0:30 ` manu at gcc dot gnu.org
2012-03-31  0:57 ` manu at gcc dot gnu.org
2012-03-31  2:16 ` paolo.carlini at oracle dot com
2012-03-31  8:24 ` paolo.carlini at oracle dot com
2012-04-01 11:24 ` manu at gcc dot gnu.org
2012-04-01 12:56 ` redi at gcc dot gnu.org
2012-04-01 13:24 ` manu at gcc dot gnu.org
2012-04-01 20:29 ` marc.glisse at normalesup dot org
2012-04-02  5:16 ` jason at gcc dot gnu.org
2012-04-02  8:17 ` manu at gcc dot gnu.org
2012-04-02 15:57 ` jason at gcc dot gnu.org
2012-04-02 17:17 ` manu at gcc dot gnu.org
2012-04-02 17:19 ` manu at gcc dot gnu.org
2012-04-02 17:20 ` manu at gcc dot gnu.org
2012-04-02 17:37 ` pinskia at gmail dot com
2012-04-02 22:06 ` jason at gcc dot gnu.org
2012-04-03  3:42 ` pinskia at gcc dot gnu.org
2012-04-04 15:27 ` manu at gcc dot gnu.org
2012-04-16 15:34 ` paolo at gcc dot gnu.org
2012-04-16 15:36 ` paolo.carlini at oracle dot com
2012-04-16 15:48 ` redi at gcc dot gnu.org
2012-04-16 16:27 ` [Bug c++/49152] pretty printer cannot handle iterators and other complex expressions manu at gcc dot gnu.org
2012-04-23 19:55 ` joseph at codesourcery dot com
2012-04-23 20:28 ` manu at gcc dot gnu.org
2013-03-22 14:48 ` jakub at gcc dot gnu.org
2013-05-31 11:03 ` jakub at gcc dot gnu.org
2013-10-16  9:51 ` jakub at gcc dot gnu.org
2015-06-22 14:26 ` rguenth at gcc dot gnu.org

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