// PR c++/49834 // PR c++/50020 // { dg-do compile { target c++11 } } struct A { template T get_value() const; }; struct B { A first, second; }; struct C { B* begin() const; B* end() const; }; template struct D { Ret f(const C &p) { for (const B &i: p) // OK i.second.get_value(); for (const auto &i: p) // ERROR i.second.get_value(); return Ret(0); } }; void g() { D().f(C()); }