Peter Maydell <peter.mayd...@linaro.org> writes: > On 1 July 2014 09:22, Paolo Bonzini <pbonz...@redhat.com> wrote: >> From: Alexey Kardashevskiy <a...@ozlabs.ru> >> >> The existing test whether "-lm" needs to be included or not is >> insufficient as it reports false negative on Fedora20/ppc64. >> This happens because sin(0.0) is a constant value which compiler >> can safely throw away and therefore there is no need to add "-lm". >> As the result, qemu-nbd/qemu-io/qemu-img tools cannot compile. >> >> This adds a global variable and uses it in the test to prevent >> from optimization. > >> --- a/configure >> +++ b/configure >> @@ -3453,7 +3453,7 @@ fi >> # Do we need libm >> cat > $TMPC << EOF >> #include <math.h> >> -int main(void) { return isnan(sin(0.0)); } >> +double x; int main(void) {return isnan(sin(x));} >> EOF >> if compile_prog "" "" ; then >> : > > This looks to me like we're leaving ourselves open for > a smarter compiler with linktime optimisation to complain > that x is used uninitialized.
x *is* initialized, to zero. A sufficiently smart compiler(TM) could figure out that x is still zero in main(), and constant fold the test away. Suggest to use argc.