mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 16:39:36 +00:00
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
This commit is contained in:
parent
333238a72a
commit
ef0a8475fd
@ -1333,7 +1333,7 @@ static NV_PAYLOAD_TYPE S_getpayload(NV nv)
|
||||
#ifdef NV_PAYLOAD_DEBUG
|
||||
Perl_warn(aTHX_ "a[%d] = %" UVxf "\n", i, a[i]);
|
||||
#endif
|
||||
payload *= UV_MAX;
|
||||
payload *= (NV) UV_MAX;
|
||||
payload += a[i];
|
||||
}
|
||||
#ifdef NV_PAYLOAD_DEBUG
|
||||
|
||||
@ -4,7 +4,7 @@ use warnings;
|
||||
|
||||
our ($AUTOLOAD, %SIGRT);
|
||||
|
||||
our $VERSION = '1.95';
|
||||
our $VERSION = '1.96';
|
||||
|
||||
require XSLoader;
|
||||
|
||||
|
||||
2
inline.h
2
inline.h
@ -1980,7 +1980,7 @@ S_lossless_NV_to_IV(const NV nv, IV *ivp)
|
||||
|
||||
/* Written this way so that with an always-false NaN comparison we
|
||||
* return false */
|
||||
if (!(LIKELY(nv >= IV_MIN) && LIKELY(nv <= IV_MAX))) {
|
||||
if (!(LIKELY(nv >= (NV) IV_MIN) && LIKELY(nv < IV_MAX_P1))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
2
pp_ctl.c
2
pp_ctl.c
@ -1228,7 +1228,7 @@ PP(pp_flop)
|
||||
if ((SvOK(left) && !SvIOK(left) && SvNV_nomg(left) < IV_MIN) ||
|
||||
(SvOK(right) && (SvIOK(right)
|
||||
? SvIsUV(right) && SvUV(right) > IV_MAX
|
||||
: SvNV_nomg(right) > IV_MAX)))
|
||||
: SvNV_nomg(right) > (NV) IV_MAX)))
|
||||
DIE(aTHX_ "Range iterator outside integer range");
|
||||
i = SvIV_nomg(left);
|
||||
j = SvIV_nomg(right);
|
||||
|
||||
4
sv.c
4
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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user