Description
"Lost precision when incrementing ... by 1
" warning on increment seems to be limited to the case that the target value was positive finite value; infinity or negative large value are not warned. (Similarly, infinity or positive large value are not warned on decrement.)
I think this is somewhat inconsistent.
Steps to Reproduce
$ perl -we 'my $x = 10 ** 300; my $y = $x++; printf "%a -> %a\n", $y, $x'
Lost precision when incrementing 100000 (snip) 540160.000000 by 1 at -e line 1.
0x1.7e43c8800759cp+996 -> 0x1.7e43c8800759cp+996
$ perl -we 'my $x = 10 ** 400; my $y = $x++; printf "%a -> %a\n", $y, $x'
Inf -> Inf
$ perl -we 'my $x = -10 ** 300; my $y = $x++; printf "%a -> %a\n", $y, $x'
-0x1.7e43c8800759cp+996 -> -0x1.7e43c8800759cp+996
The second and third example above shows that target variable are not changed, but no warnings are generated.
Expected behavior
I expect that perl will warn if increment cannot change the value even for infinite or negative values, and for decrement, warn even for infinite or positive values.
Perl configuration
Summary of my perl5 (revision 5 version 33 subversion 4) configuration:
Commit id: 185eb2d3f6e86edc749ad9b20f1b6a1e0b231ad7
Platform:
osname=linux
osvers=4.19.0-12-686-pae
archname=i686-linux
uname='linux x41 4.19.0-12-686-pae #1 smp debian 4.19.152-1 (2020-10-18) i686 gnulinux '
config_args='-de -Dusedevel -DEBUGGING'
hint=recommended
useposix=true
d_sigaction=define
useithreads=undef
usemultiplicity=undef
use64bitint=undef
use64bitall=undef
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='cc'
ccflags ='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
optimize='-O2 -g'
cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
ccversion=''
gccversion='8.3.0'
gccosandvers=''
intsize=4
longsize=4
ptrsize=4
doublesize=8
byteorder=1234
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=12
longdblkind=3
ivtype='long'
ivsize=4
nvtype='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=4
prototype=define
Linker and Libraries:
ld='cc'
ldflags =' -fstack-protector-strong -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib/gcc/i686-linux-gnu/8/include-fixed /usr/include/i386-linux-gnu /usr/lib /lib/i386-linux-gnu /lib/../lib /usr/lib/i386-linux-gnu /usr/lib/../lib /lib /lib64 /usr/lib64
libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
libc=libc-2.28.so
so=so
useshrplib=false
libperl=libperl.a
gnulibc_version='2.28'
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=so
d_dlsymun=undef
ccdlflags='-Wl,-E'
cccdlflags='-fPIC'
lddlflags='-shared -O2 -g -L/usr/local/lib -fstack-protector-strong'
Characteristics of this binary (from libperl):
Compile-time options:
DEBUGGING
HAS_TIMES
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_DEVEL
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
Built under linux
Compiled at Nov 15 2020 18:25:29
@INC:
/usr/local/lib/perl5/site_perl/5.33.4/i686-linux
/usr/local/lib/perl5/site_perl/5.33.4
/usr/local/lib/perl5/5.33.4/i686-linux
/usr/local/lib/perl5/5.33.4
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4