[Bug c++/82125] New: Suboptimal error message for range-based for
rs2740 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Sep 6 23:15:00 GMT 2017
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.
More information about the Gcc-bugs
mailing list