aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/bitfld-10.c
blob: bdbf5733ce7fba23f8ab4d33622d98fd5520ba86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* PR tree-optimization/102622 */
/* Wrong code introduced due to phi-opt
   introducing undefined signed interger overflow
   with one bit signed integer negation. */

struct f{signed t:1;};
int g(struct f *a, int t) __attribute__((noipa));
int g(struct f *a, int t)
{
    if (t)
      a->t = -1;
    else
      a->t = 0;
    int t1 = a->t;
    if (t1) return 1;
    return t1;
}

int main(void)
{
    struct f a;
    if (!g(&a, 1))  __builtin_abort();
    return 0;
}