gcc/testsuite/gcc.dg/torture/pr26258.c
raw| 1 | /* { dg-do run } */ |
| 2 | |
| 3 | extern void abort(void); |
| 4 | |
| 5 | typedef struct Foo { int a; int b; } Foo; |
| 6 | |
| 7 | Foo foo(Foo first, Foo last, _Bool ret_first) |
| 8 | { |
| 9 | Foo t; |
| 10 | Foo *t1 = (ret_first ? &first : &last); |
| 11 | first.a = 2; |
| 12 | last.b = 3; |
| 13 | t.a = t1->a; |
| 14 | t.b = t1->b; |
| 15 | t.a += first.a; |
| 16 | t.b += last.b; |
| 17 | return t; |
| 18 | } |
| 19 | |
| 20 | int main() |
| 21 | { |
| 22 | Foo first = (Foo){1, 2}; |
| 23 | Foo last = (Foo){3, 4}; |
| 24 | Foo ret = foo(first, last, 0); |
| 25 | if (ret.b != 6) |
| 26 | abort (); |
| 27 | return 0; |
| 28 | } |