[resend: the first time the message didn't get through because
miscategorized as spam]
Hi,
I'm adding the testcase to mainline and closing the PR.
Thanks,
Paolo.
/////////////////////
2011-12-27 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51547
* g++.dg/cpp0x/pr51547.C: New.
Index: g++.dg/cpp0x/pr51547.C
===================================================================
--- g++.dg/cpp0x/pr51547.C (revision 0)
+++ g++.dg/cpp0x/pr51547.C (revision 0)
@@ -0,0 +1,50 @@
+// PR c++/51547
+// { dg-options "-std=c++0x" }
+
+template <class T>
+struct vector
+{
+ T*
+ begin()
+ { return &member; }
+
+ const T*
+ begin() const
+ { return &member; }
+
+ T member;
+};
+
+struct Bar {
+ int x;
+};
+
+struct Foo {
+ const vector<Bar>& bar() const {
+ return bar_;
+ }
+
+ vector<Bar> bar_;
+};
+
+template <class X>
+struct Y {
+ void foo() {
+ Foo a;
+ auto b = a.bar().begin();
+ auto&& c = b->x;
+ }
+};
+
+template <class X>
+void foo() {
+ Foo a;
+ auto b = a.bar().begin();
+ auto&& c = b->x;
+}
+
+int main() {
+ Y<int> p;
+ p.foo();
+ foo<int>();
+}