http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53001
Bug #: 53001
Summary: -Wfloat-conversion should be available to warn about
floating point errors
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
This is a request to add a new warning that warns on the subset of -Wconversion
warnings that involve floating point numbers. For example, with
-Wfloat-conversion this would cause a warning:
int main(int argc, char ** argv) {
int i = 3.14;
return i;
}
I think this could mostly be done by modifying gcc/c-family/c-common.c
unsafe_conversion_p to add the ability to only warn on conversions where
REAL_TYPE or REAL_CST are involved.
The reason -Wconversion is not sufficient is that using it can cause hundreds
of warnings, almost all of which are integer size warnings (many of which are
in libraries (such as libMesh)). I would like to be able to enable something
like -Wfloat-conversion that would catch errors involving floating point number
conversions, while ignoring the integer size conversions.