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?

Reply via email to