This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82125] New: Suboptimal error message for range-based for
- From: "rs2740 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 06 Sep 2017 23:15:02 +0000
- Subject: [Bug c++/82125] New: Suboptimal error message for range-based for
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82125
Bug ID: 82125
Summary: Suboptimal error message for range-based for
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rs2740 at gmail dot com
Target Milestone: ---
void meow() {
int a[3][4];
for(const auto r : a)
for(auto e : r) {}
}
This emits
prog.cc: In function 'void meow()':
prog.cc:4:22: error: 'begin' was not declared in this scope
for(auto e : r) {}
^
prog.cc:4:22: error: 'end' was not declared in this scope
which, while not inaccurate, isn't helpful either. There is literally no scope
in which begin/end can be looked up, because int* has no associated namespace
whatsoever.
Moreover, if some begin/end is around - say, via #include <iterator> - then we
get a list of "suggested alternatives". But that seems even less helpful since
the form of the call is hard-coded in the language and isn't something the
programmer has any control over.