diff mbox

[C++,testcase,commited] PR 51547

Message ID 4EFB1DFD.1010202@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Dec. 28, 2011, 1:47 p.m. UTC
[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.carlini@oracle.com>

	PR c++/51547
	* g++.dg/cpp0x/pr51547.C: New.
diff mbox

Patch

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>();
+}