summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-11-22 09:36:20 -0700
committerKarl Williamson <khw@cpan.org>2020-11-22 09:47:15 -0700
commitef0a8475fdfef2bfeb82df0df1e8cc211790721e (patch)
tree9134373de2a9124beead7b839d4abc5ce01aa1ff /sv.c
parent333238a72a681884a924eb094c6f4d337b82b540 (diff)
downloadperl-ef0a8475fdfef2bfeb82df0df1e8cc211790721e.tar.gz
Slience compiler warnings for NV, [IU]V compare
These were occurring on FreeBSD smokes. warning: implicit conversion from 'IV' (aka 'long') to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion] 9223372036854775807 is IV_MAX. What needed to be done here was to use the NV containing IV_MAX+1, a value that already exists in perl.h In other instances, simply casting to an NV before doing the comparison with the NV was what was needed. This fixes #18328
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sv.c b/sv.c
index f062cc2ad2..5c4c355555 100644
--- a/sv.c
+++ b/sv.c
@@ -2055,7 +2055,7 @@ S_sv_2iuv_non_preserve(pTHX_ SV *const sv
(void)SvNOK_on(sv);
/* Can't use strtol etc to convert this string. (See truth table in
sv_2iv */
- if (SvNVX(sv) <= (UV)IV_MAX) {
+ if (SvNVX(sv) < IV_MAX_P1) {
SvIV_set(sv, I_V(SvNVX(sv)));
if ((NV)(SvIVX(sv)) == SvNVX(sv)) {
SvIOK_on(sv); /* Integer is precise. NOK, IOK */
@@ -11118,7 +11118,7 @@ S_F0convert(NV nv, char *const endbuf, STRLEN *const len)
assert(!Perl_isinfnan(nv));
if (neg)
nv = -nv;
- if (nv != 0.0 && nv < UV_MAX) {
+ if (nv != 0.0 && nv < (NV) UV_MAX) {
char *p = endbuf;
uv = (UV)nv;
if (uv != nv) {