repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
PR c++/87109 - wrong ctor with maybe-rvalue semantics.
[official-gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
cpp0x
/
ref-qual20.C
blob
c8bd43643af64612d14e520af37f529dceed7e32
1
// PR c++/87109
2
// { dg-do run { target c++11 } }
3
4
#include <utility>
5
6
struct Y {
7
int y;
8
Y(int y_) : y(y_) { }
9
};
10
struct X : public Y {
11
int x;
12
X(int x_, int y_) : x(x_), Y(y_) { }
13
};
14
15
struct A {
16
operator X() & { return { 0, 2 }; }
17
operator X() && { return { 0, -1 }; }
18
};
19
20
Y
21
f (A a)
22
{
23
return a;
24
}
25
26
Y
27
f2 (A a)
28
{
29
return std::move (a);
30
}
31
32
Y
33
f3 ()
34
{
35
A a;
36
return a;
37
}
38
39
Y
40
f4 ()
41
{
42
A a;
43
return std::move (a);
44
}
45
46
Y
47
f5 ()
48
{
49
return A();
50
}
51
52
int
53
main ()
54
{
55
Y y1 = f (A());
56
if (y1.y != 2)
57
__builtin_abort ();
58
Y y2 = f2 (A());
59
if (y2.y != -1)
60
__builtin_abort ();
61
Y y3 = f3 ();
62
if (y3.y != 2)
63
__builtin_abort ();
64
Y y4 = f4 ();
65
if (y4.y != -1)
66
__builtin_abort ();
67
Y y5 = f5 ();
68
if (y5.y != -1)
69
__builtin_abort ();
70
}