1// { dg-do run } 2// PRMS Id: 3744 3// Bug: unswitching a COND_EXPR initializer fails to set SIDE_EFFECTS on the 4// result, so expand_expr ignores it. 5 6extern "C" { 7 int printf(const char *,...); 8 void exit(int); 9} 10 11struct A { 12 int x; 13 int y; 14 15 A() : x(0), y(0) { } 16}; 17 18struct S { 19 S() : flags(0) { } 20 unsigned flags; 21 A from; 22 void foo(const A &pos); 23}; 24 25void S::foo(const A &pos) 26{ 27 A a = flags ? from : pos; 28 printf("%d %d\n", a.x, a.y); 29 if (a.x != 17 || a.y != 12) 30 exit (1); 31} 32 33int main() 34{ 35 A pos; 36 pos.x = 17; 37 pos.y = 12; 38 S s; 39 s.foo(pos); 40 return 0; 41} 42