From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20960 invoked by alias); 24 May 2011 21:30:56 -0000 Received: (qmail 20938 invoked by uid 22791); 24 May 2011 21:30:55 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 May 2011 21:30:41 +0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/49152] New: Unhelpful diagnostic for iterator dereference X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 24 May 2011 21:43:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg02260.txt.bz2 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 struct X { }; struct Y { } val; std::vector::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, __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 > >::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