view gcc/testsuite/gcc.dg/torture/ftrapv-1.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
line wrap: on
line source

/* { dg-do run } */
/* { dg-additional-options "-ftrapv -fno-ipa-vrp" } */
/* { 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/52478  */

/* Disallow inlining/cloning which would constant propagate and trigger
   unrelated bugs.  */

int __attribute__((noipa))
iaddv (int a, int b)
{
  return a + b;
}

int main(void)
{
  pid_t child = fork ();
  int status = 0;
  if (child == 0)
    {
      volatile int x = iaddv (__INT_MAX__, 1);
      exit (0);
    }
  else if (child == -1)
    return 0;
  if (wait (&status) == child 
      && status == 0)
    abort ();
  return 0;
}