aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/signed1bitfield-1.c
blob: ab888ca3a0489d454814593e7c95b693dbed6059 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* PR tree-optimization/115154 */
/* This was being miscompiled to `(signed:1)(t*5)`
   being transformed into `-((signed:1)t)` which is undefined.
   Note there is a pattern which removes the negative in some cases
   which works around the issue.  */

struct {
  signed b : 1;
} f;
int i = 55;
__attribute__((noinline))
void check(int a)
{
        if (!a)
        __builtin_abort();
}
int main() {
    int t = i != 5;
    t = t*5;
    f.b = t;
    int tt = f.b;
    check(f.b);
}