Description
When used in a foreach loop, builtin::trim returns the same PV in subsequent iterations which then numifies to the same IV as in the first loop even though the PV has changed.
Reported by damien on IRC
Steps to Reproduce
perl -Mv5.40 -MDevel::Peek -E'for my $i ("4" .. "5") { Dump builtin::trim($i); Dump 0+builtin::trim($i) }'
SV = PV(0xd61dbc0) at 0xd65ba58
REFCNT = 1
FLAGS = (PADTMP,POK,pPOK)
PV = 0xd5cce70 "4"\0
CUR = 1
LEN = 16
SV = IV(0xd65b970) at 0xd65b980
REFCNT = 1
FLAGS = (PADTMP,IOK,pIOK)
IV = 4
SV = PV(0xd61dbc0) at 0xd65ba58
REFCNT = 1
FLAGS = (PADTMP,POK,pPOK)
PV = 0xd5cce70 "5"\0
CUR = 1
LEN = 16
SV = IV(0xd65b970) at 0xd65b980
REFCNT = 1
FLAGS = (PADTMP,IOK,pIOK)
IV = 4
Expected behavior
outputting a PV of '4', IV of 4, PV of '5', and IV of 5
Perl configuration
Summary of my perl5 (revision 5 version 40 subversion 0) configuration:
Platform:
osname=linux
osvers=6.3.8-200.fc38.x86_64
archname=x86_64-linux
uname='linux home.grinnz.com 6.3.8-200.fc38.x86_64 #1 smp preempt_dynamic thu jun 15 02:15:40 utc 2023 x86_64 gnulinux '
config_args='-Dprefix=/home/grinnz/.plenv/versions/5.40.0 -de -Dversiononly -A'eval:scriptdir=/home/grinnz/.plenv/versions/5.40.0/bin''
hint=recommended
useposix=true
d_sigaction=define
useithreads=undef
usemultiplicity=undef
use64bitint=define
use64bitall=define
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='cc'
ccflags ='-fwrapv -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'
cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
ccversion=''
gccversion='13.2.1 20231011 (Red Hat 13.2.1-4)'
gccosandvers=''
intsize=4
longsize=8
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='cc'
ldflags =' -fstack-protector-strong -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib /usr/lib64 /usr/local/lib64
libs=-lpthread -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
libc=/lib/../lib64/libc.so.6
so=so
useshrplib=false
libperl=libperl.a
gnulibc_version='2.37'
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=so
d_dlsymun=undef
ccdlflags='-Wl,-E'
cccdlflags='-fPIC'
lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'
Characteristics of this binary (from libperl):
Compile-time options:
HAS_LONG_DOUBLE
HAS_STRTOLD
HAS_TIMES
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_SIPHASH13
PERL_HASH_USE_SBOX32
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_SAFE_PUTENV
USE_64_BIT_ALL
USE_64_BIT_INT
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 Jun 10 2024 21:21:12
@INC:
/home/grinnz/.plenv/versions/5.40.0/lib/perl5/site_perl/5.40.0/x86_64-linux
/home/grinnz/.plenv/versions/5.40.0/lib/perl5/site_perl/5.40.0
/home/grinnz/.plenv/versions/5.40.0/lib/perl5/5.40.0/x86_64-linux
/home/grinnz/.plenv/versions/5.40.0/lib/perl5/5.40.0
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