OSDN Git Service

2011-12-27 Paolo Carlini <paolo.carlini@oracle.com>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Dec 2011 19:04:24 +0000 (19:04 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Dec 2011 19:04:24 +0000 (19:04 +0000)
PR c++/51547
* g++.dg/cpp0x/pr51547.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182695 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/g++.dg/cpp0x/pr51547.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/cpp0x/pr51547.C b/gcc/testsuite/g++.dg/cpp0x/pr51547.C
new file mode 100644 (file)
index 0000000..80215f6
--- /dev/null
@@ -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>();
+}