This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/82125] New: Suboptimal error message for range-based for


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]