mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-30 14:35:11 +08:00
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
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…
Reference in New Issue
Block a user