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
This commit is contained in:
Paolo Carlini 2011-12-27 19:04:24 +00:00
parent 282bc7b4c5
commit 7004306f7c

View File

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