[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH fix for 2.1] makefile: Fix tools compile
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH fix for 2.1] makefile: Fix tools compile |
Date: |
Tue, 1 Jul 2014 09:19:17 +0100 |
On 1 July 2014 07:52, Paolo Bonzini <address@hidden> wrote:
> Il 01/07/2014 07:42, Alexey Kardashevskiy ha scritto:
>
>> This is wrong actually. The problem here that compiler knows how to
>> optimize constants. sin(0.0) is the one while log(0.0) is not (it is
>> supposed to throw error or something as it the result is infinity).
>>
>> So the correct test here could be:
>> int main(void) { volatile double x = 1; return isnan(sin(x)); }
>>
>> But I am afraid pretty soon compilers will learn how to optimize this as
>> well :)
>
>
> I think something like "double x; int f(void) {return isnan(sin(x));}"
> should be bullet proof.
This is a compile_prog test, though -- the compiler could spot
that x and f are both unused, since it has the entire program
in hand. My suggestion would be:
int main(int argc, char **argv) { return isnan(sin((double)argc)); }
thanks
-- PMM