From 7004306f7c968223ecdbe912c47dec70c2ed3d53 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 27 Dec 2011 19:04:24 +0000 Subject: [PATCH] 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 PR c++/51547 * g++.dg/cpp0x/pr51547.C: New. From-SVN: r182695 --- gcc/testsuite/g++.dg/cpp0x/pr51547.C | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr51547.C diff --git a/gcc/testsuite/g++.dg/cpp0x/pr51547.C b/gcc/testsuite/g++.dg/cpp0x/pr51547.C new file mode 100644 index 00000000000..80215f6a341 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr51547.C @@ -0,0 +1,50 @@ +// PR c++/51547 +// { dg-options "-std=c++0x" } + +template +struct vector +{ + T* + begin() + { return &member; } + + const T* + begin() const + { return &member; } + + T member; +}; + +struct Bar { + int x; +}; + +struct Foo { + const vector& bar() const { + return bar_; + } + + vector bar_; +}; + +template +struct Y { + void foo() { + Foo a; + auto b = a.bar().begin(); + auto&& c = b->x; + } +}; + +template +void foo() { + Foo a; + auto b = a.bar().begin(); + auto&& c = b->x; +} + +int main() { + Y p; + p.foo(); + foo(); +}