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:
parent
282bc7b4c5
commit
7004306f7c
1 changed files with 50 additions and 0 deletions
50
gcc/testsuite/g++.dg/cpp0x/pr51547.C
Normal file
50
gcc/testsuite/g++.dg/cpp0x/pr51547.C
Normal 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>();
|
||||
}
|
Loading…
Add table
Reference in a new issue