Debian Codegraph @

gcc/testsuite/g++.dg/overload/cond1.C

raw
1 // Test that converting a COND_EXPR to void doesn't result in trying to
2 // bitwise copy a class with a nontrivial copy constructor (and thus a
3 // compiler abort).
4
5 // { dg-options "-O" }
6
7 struct A {
8 virtual ~A() { }
9 };
10
11 A a1, a2;
12 inline A& one () { return a1; }
13 inline A& two () { return a2; }
14
15 inline void f (int i)
16 {
17 i ? a1 : a2;
18 i ? one() : two();
19 }
20
21 int main ()
22 {
23 f (1);
24 }