(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
torture/
ftrapv-1.c
       1  /* { dg-do run } */
       2  /* { dg-additional-options "-ftrapv -fno-ipa-vrp" } */
       3  /* { dg-require-effective-target trapping } */
       4  /* { dg-require-fork "" } */
       5  
       6  #include <stdlib.h>
       7  #include <unistd.h>
       8  #include <sys/types.h>
       9  #include <sys/wait.h>
      10  
      11  /* Verify SImode operations properly trap.  PR middle-end/52478  */
      12  
      13  /* Disallow inlining/cloning which would constant propagate and trigger
      14     unrelated bugs.  */
      15  
      16  int __attribute__((noipa))
      17  iaddv (int a, int b)
      18  {
      19    return a + b;
      20  }
      21  
      22  int main(void)
      23  {
      24    pid_t child = fork ();
      25    int status = 0;
      26    if (child == 0)
      27      {
      28        volatile int x = iaddv (__INT_MAX__, 1);
      29        exit (0);
      30      }
      31    else if (child == -1)
      32      return 0;
      33    if (wait (&status) == child 
      34        && status == 0)
      35      abort ();
      36    return 0;
      37  }