summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-11-08 16:55:28 +0000
committerDavid Mitchell <davem@iabyn.com>2013-11-09 13:09:56 +0000
commitc279c4550ce59702722d0921739b1a1b92701b0d (patch)
tree24ee3a0f32ed60677664c7e43a5b3a52523948b8 /pp_sys.c
parentb78a1974184592bd724e6c3f7a8b1e7d7aa63056 (diff)
downloadperl-c279c4550ce59702722d0921739b1a1b92701b0d.tar.gz
make perl core quiet under -Wfloat-equal
The gcc option -Wfloat-equal warns when two floating-point numbers are directly compared for equality or inequality, the idea being that this is usually a logic error, and that you should be checking that the values are instead very near to each other. perl on the other hand has lots of reasons to do a direct comparison. Add two macros, NV_eq_nowarn(a,b) and NV_eq_nowarn(a,b) that do the same as (a == b) and (a != b), but without the warnings. They achieve this by instead doing (a < b) || ( a > b). Under gcc at least, this is optimised into the same code as the direct comparison. The are three places that I've left untouched, because they are handling NaNs, and that gets a bit tricky. In particular (nv != nv) is a test for a NaN, and replacing it with (< || >) creates signalling NaNs (whereas == and != create quiet NaNs)
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 78308f44ab..92d4c608f6 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4466,7 +4466,7 @@ PP(pp_gmtime)
else {
NV input = Perl_floor(POPn);
when = (Time64_T)input;
- if (when != input) {
+ if (NV_ne_nowarn(when, input)) {
/* diag_listed_as: gmtime(%f) too large */
Perl_ck_warner(aTHX_ packWARN(WARN_OVERFLOW),
"%s(%.0" NVff ") too large", opname, input);