From: | "Steven G. Kargl" <sgk@troutmask.apl.washington.edu> |
Newsgroups: | comp.compilers |
Date: | Thu, 24 Oct 2013 16:38:13 +0000 (UTC) |
Organization: | A noiseless patient Spider |
References: | 13-10-026 13-10-029 <13-10-030 @comp.compilers> |
Keywords: | arithmetic, comment |
Posted-Date: | 24 Oct 2013 16:44:01 EDT |
On Thu, 24 Oct 2013 15:51:59 +0200, Jean-Marc Bourguet wrote:
> George Neuner <gneuner2@comcast.net> writes:
>
>> [I think you mean they're not associative. I don't know any situations
>> where a+b != b+a, but lots where a+(b+c) != (a+b)+c -John]
>
> You forgot about NaN ;-) (but I agree associative was probably intended).
>
> Yours,
> --
> Jean-Marc [How are NaNs not commutative? -John]
I believe Jean-Marc is referring to something like the following
#include <stdio.h>
int
main(void)
{
float a, b;
a = 0.;
b = a / a;
if (a + b != b + a) printf("fubar\n");
return (0);
}
Can an optimizing compiler eliminate the if-statement?
--
steve
[If it does sufficient dataflow and constant substitutions so it can tell
that a+b will always be a NaN, I don't see why not. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.