gcc/testsuite/gcc.c-torture/execute/signed1bitfield-1.c
raw| 1 | /* PR tree-optimization/115154 */ |
| 2 | /* This was being miscompiled to `(signed:1)(t*5)` |
| 3 | being transformed into `-((signed:1)t)` which is undefined. |
| 4 | Note there is a pattern which removes the negative in some cases |
| 5 | which works around the issue. */ |
| 6 | |
| 7 | struct { |
| 8 | signed b : 1; |
| 9 | } f; |
| 10 | int i = 55; |
| 11 | __attribute__((noinline)) |
| 12 | void check(int a) |
| 13 | { |
| 14 | if (!a) |
| 15 | __builtin_abort(); |
| 16 | } |
| 17 | int main() { |
| 18 | int t = i != 5; |
| 19 | t = t*5; |
| 20 | f.b = t; |
| 21 | int tt = f.b; |
| 22 | check(f.b); |
| 23 | } |