summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/ieee/mzero5.c
blob: 3804c08a80a7633768eeaccbef3282b0c6aa8c50 (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
/* Test gcse handling of IEEE 0/-0 rules.  */
static double zero = 0.0;

int
negzero_check (double d)
{
  if (d == 0)
    return !!memcmp ((void *)&zero, (void *)&d, sizeof (double));
  return 0;
}

int
sub (double d, double e)
{
  if (d == 0.0 && e == 0.0
      && negzero_check (d) == 0 && negzero_check (e) == 0)
    return 1;
  else
    return 0;
}

int
main (void)
{
  double minus_zero = -0.0;
  if (sub (minus_zero, 0))
    abort ();
  return 0;
}