aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/ftrapv-2.c
blob: 4d746c9ce5c222dce410dbfc8c49ce1c7ce61d51 (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
25
26
27
28
29
30
31
32
/* { dg-do run } */
/* With -flto this degenerates to constant folding which doesn't work.  */
/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
/* { dg-additional-options "-ftrapv" } */
/* { dg-require-effective-target trapping } */
/* { dg-require-fork "" } */

#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

/* Verify SImode operations properly trap.  PR middle-end/68046 */

volatile int i = 0x7fffffff;

int main(void)
{
  pid_t child = fork ();
  int status = 0;
  if (child == 0)
    {
      i = i + 1;
      exit (0);
    }
  else if (child == -1)
    return 0;
  if (wait (&status) == child 
      && status == 0)
    abort ();
  return 0;
}