blob: 7a2616a2017fc6fff432da93187a3485dcc8dce5 (
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
|
/* Tail call optimizations would convert func() into the moral equivalent of:
double acc = 0.0;
for (int i = 0; i <= n; i++)
acc += d;
return acc;
which mishandles the case where 'd' is -0. They also initialised 'acc'
to a zero int rather than a zero double. */
void abort (void);
void exit (int);
double func (double d, int n)
{
if (n == 0)
return d;
else
return d + func (d, n - 1);
}
int main ()
{
if (__builtin_copysign (1.0, func (0.0 / -5.0, 10)) != -1.0)
abort ();
exit (0);
}
|