diff options
author | Karl Williamson <khw@cpan.org> | 2019-04-28 17:42:44 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-05-24 17:09:30 -0600 |
commit | 3a019afd6f6291c3249c254b5c01e244e4ec83ab (patch) | |
tree | 290e919ac77aaf28cee53b4524606f3fb8714422 /pp_hot.c | |
parent | 190e86d7a39dad04ad5d024fb42c0b8fefa68ebe (diff) | |
download | perl-3a019afd6f6291c3249c254b5c01e244e4ec83ab.tar.gz |
Create fcn for lossless conversion of NV to IV
Essentially the same code was being used in three places, and had
undefined C behavior for some inputs.
This consolidates the code into one inline function, and rewrites it to
avoid undefined behavior.
Diffstat (limited to 'pp_hot.c')
-rw-r--r-- | pp_hot.c | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -1435,16 +1435,10 @@ PP(pp_add) NV nl = SvNVX(svl); NV nr = SvNVX(svr); - if ( -#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan) - !Perl_isnan(nl) && nl == (NV)(il = (IV)nl) - && !Perl_isnan(nr) && nr == (NV)(ir = (IV)nr) -#else - nl == (NV)(il = (IV)nl) && nr == (NV)(ir = (IV)nr) -#endif - ) + if (lossless_NV_to_IV(nl, &il) && lossless_NV_to_IV(nr, &ir)) { /* nothing was lost by converting to IVs */ goto do_iv; + } SP--; TARGn(nl + nr, 0); /* args not GMG, so can't be tainted */ SETs(TARG); |