Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/ieee/mzero6.c

raw
1 /* Tail call optimizations would convert func() into the moral equivalent of:
2
3 double acc = 0.0;
4 for (int i = 0; i <= n; i++)
5 acc += d;
6 return acc;
7
8 which mishandles the case where 'd' is -0. They also initialised 'acc'
9 to a zero int rather than a zero double. */
10
11 void abort (void);
12 void exit (int);
13
14 double func (double d, int n)
15 {
16 if (n == 0)
17 return d;
18 else
19 return d + func (d, n - 1);
20 }
21
22 int main ()
23 {
24 if (__builtin_copysign (1.0, func (0.0 / -5.0, 10)) != -1.0)
25 abort ();
26 exit (0);
27 }