Commit 7004306f by Paolo Carlini

re PR c++/51547 (auto, type deduction, reference collapsing and const: invalid…

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
parent 282bc7b4
// 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>();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment