view gcc/testsuite/gcc.dg/pr78185.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */
/* { dg-options "-O" } */

#include <unistd.h>
#include <signal.h>
#include <stdlib.h>

static char var1 = 0L;
static char *var2 = &var1;

void do_exit (int i)
{
  exit (0);
}

int main(void)
{
  struct sigaction s;
  sigemptyset (&s.sa_mask);
  s.sa_handler = do_exit;
  s.sa_flags = 0;
  sigaction (SIGALRM, &s, NULL);
  alarm (1);
  /* The following loop is infinite, the division by zero should not
     be hoisted out of it.  */
  for (; (var1 == 0 ? 0 : (100 / var1)) == *var2; );
  return 0;
}