Debian Codegraph @

gcc/testsuite/c-c++-common/ubsan/signed1bitfield-1.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fsanitize=undefined" } */
3
4 /* PR tree-optimization/115154 */
5 /* This was being miscompiled with -fsanitize=undefined due to
6 `(signed:1)(t*5)` being transformed into `-((signed:1)t)` which
7 is undefined. */
8
9 struct s {
10 signed b : 1;
11 } f;
12 int i = 55;
13 __attribute__((noinline))
14 void check(int a)
15 {
16 if (!a)
17 __builtin_abort();
18 }
19 int main() {
20 int t = i != 5;
21 t = t*5;
22 f.b = t;
23 int tt = f.b;
24 check(f.b);
25 }