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++/71010] New: error: 'begin' was not declared in this scope


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71010

            Bug ID: 71010
           Summary: error: 'begin' was not declared in this scope
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: theubik at mail dot ru
  Target Milestone: ---

For example:

// https://godbolt.org/g/Zp5ABy
#include <iostream>
class X
{
  int m_x[5] = { 0, 1, 2, 3, 4 };
public:
  int* first() { return &m_x[0]; }
  int* last() { return &m_x[4]; }
};

namespace std
{
  int* begin(X& x) { return x.first(); }
  int* end(X& x) { return x.last(); }
}

int main()
{
  X x;
  for (auto xi : x) // error: 'begin' was not declared in this scope
    std::cout << xi << std::endl;
  return 0;
}

With gcc 4.8 is OK. This is bug?

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