Debian Codegraph @

gcc/testsuite/g++.dg/opt/nrv8.C

raw
1 // PR optimization/19531
2 // forbids NRV on volatile return value.
3 // { dg-options -O2 }
4 // { dg-do run }
5
6 extern "C" { void abort(); }
7
8 struct A
9 {
10 int d;
11
12 A () { d = 123; }
13 A (const A & o) { d = o.d; }
14 A (volatile const A & o) { d = o.d + 2; }
15 };
16
17 A bar()
18 {
19 volatile A l;
20 return l;
21 }
22
23 int main()
24 {
25 A a = bar ();
26
27 if (a.d != 125)
28 abort();
29
30 return 0;
31 }