aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo@gcc.gnu.org>2011-12-27 19:04:24 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2011-12-27 19:04:24 +0000
commit7004306f7c968223ecdbe912c47dec70c2ed3d53 (patch)
tree4d94dadddd9aafd17cde096e1881a40a0dcd123b
parent282bc7b4c5fd895ecc81781e0febb8ec13d9ad86 (diff)
downloadgcc-7004306f7c968223ecdbe912c47dec70c2ed3d53.zip
gcc-7004306f7c968223ecdbe912c47dec70c2ed3d53.tar.gz
gcc-7004306f7c968223ecdbe912c47dec70c2ed3d53.tar.bz2
re PR c++/51547 (auto, type deduction, reference collapsing and const: invalid initialization of reference of type 'const X&&' from expression of type 'const X')
2011-12-27 Paolo Carlini <paolo.carlini@oracle.com> PR c++/51547 * g++.dg/cpp0x/pr51547.C: New. From-SVN: r182695
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr51547.C50
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr51547.C b/gcc/testsuite/g++.dg/cpp0x/pr51547.C
new file mode 100644
index 0000000..80215f6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr51547.C
@@ -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>();
+}