https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61501
Bug ID: 61501
Summary: spurious conversion warning with -Wconversion when
calling isnan(double x)
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: niemayer at isg dot de
When compiling:
--------------------------
#include <math.h>
int test(double x) {
return isnan(x);
}
--------------------------
with
gcc-4.9.0 -Wconversion -c /tmp/conversion_warn.cxx
a spurious warning is emitted:
/tmp/conversion_warn.cxx: In function 'int test(double)':
/tmp/conversion_warn.cxx:4:9: warning: conversion to 'float' from 'double' may
alter its value [-Wfloat-conversion]
return isnan(x);
^
This is what the output of compiling with "-E" of the above sample looks (with
includes from glibc 2.5.1):
-----------------------------
int test(double x) {
return (sizeof (x) == sizeof (float) ? __isnanf (x) : sizeof (x) == sizeof
(double) ? __isnan (x) : __isnanl (x));
}
-----------------------------
(This looks a little like Bug 51294, but that was reported fixed a long time
ago.)