develooper Front page | perl.perl5.porters | Postings from August 2019

int() should not change the state of the scalar

Thread Next
From:
Ovid via perl5-porters
Date:
August 29, 2019 13:01
Subject:
int() should not change the state of the scalar
Message ID:
479448884.216595.1567083672617@mail.yahoo.com
 My apologies if this is a duplicate bug report.
This is a bug report for perl from ovid@allaroundtheworld.fr,
generated with the help of perlbug 1.40 running under perl 5.26.2.


-----------------------------------------------------------------
[Please describe your issue here]

Calling int() in a scalar with a floating point number causes the pIOK flag to be set.

This has led to a bug in Types::Standard: https://rt.cpan.org/Public/Bug/Display.html?id=130411

I believe int() should be a pure function and not change the state of the scalar. The
following illustrates the issue:

    $ perl -MDevel::Peek -E 'my $num = 3.14; Dump($num); int($num); Dump($num)'
    SV = NV(0x7fa846016d68) at 0x7fa846016d80
      REFCNT = 1
      FLAGS = (NOK,pNOK)
      NV = 3.14
    SV = PVNV(0x7fa846001ab0) at 0x7fa846016d80
      REFCNT = 1
      FLAGS = (NOK,pIOK,pNOK)
      IV = 3
      NV = 3.14
      PV = 0

Best,
Ovid

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl 5.26.2:

Configured by ovid at Wed Mar 27 14:08:04 CET 2019.

Summary of my perl5 (revision 5 version 26 subversion 2) configuration:
   
  Platform:
    osname=darwin
    osvers=18.2.0
    archname=darwin-2level
    uname='darwin overseas-exile 18.2.0 darwin kernel version 18.2.0: thu dec 20 20:46:53 pst 2018; root:xnu-4903.241.1~1release_x86_64 x86_64 '
    config_args='-de -Dprefix=/Users/ovid/perl5/perlbrew/perls/perl-5.26.2 -Aeval:scriptdir=/Users/ovid/perl5/perlbrew/perls/perl-5.26.2/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
    bincompat5005=undef
  Compiler:
    cc='cc'
    ccflags ='-fno-common -DPERL_DARWIN -mmacosx-version-min=10.14 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -DPERL_USE_SAFE_PUTENV'
    optimize='-O3'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=10.14 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.3)'
    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 =' -mmacosx-version-min=10.14 -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib /usr/lib
    libs=-lpthread -lgdbm -ldbm -ldb -ldl -lm -lutil -lc
    perllibs=-lpthread -ldl -lm -lutil -lc
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=10.14 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong'

Locally applied patches:
    Devel::PatchPerl 1.56

---
@INC for perl 5.26.2:
    lib
    /Users/ovid/perl5/perlbrew/perls/perl-5.26.2/lib/site_perl/5.26.2/darwin-2level
    /Users/ovid/perl5/perlbrew/perls/perl-5.26.2/lib/site_perl/5.26.2
    /Users/ovid/perl5/perlbrew/perls/perl-5.26.2/lib/5.26.2/darwin-2level
    /Users/ovid/perl5/perlbrew/perls/perl-5.26.2/lib/5.26.2

---
Environment for perl 5.26.2:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/ovid
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_CTYPE=UTF-8
    LC_TERMINAL=iTerm2
    LC_TERMINAL_VERSION=3.3.2
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/Users/ovid/node/bin:/usr/local/opt/postgresql@9.6/bin:/opt/rakudo-star-2018.04/bin:/opt/rakudo-star-2018.04/share/perl6/site/bin:/Users/ovid/bin:/Users/ovid/perl5/perlbrew/bin:/Users/ovid/perl5/perlbrew/perls/perl-5.26.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Users/ovid/node/bin:/usr/local/opt/postgresql@9.6/bin:/opt/rakudo-star-2018.04/bin:/opt/rakudo-star-2018.04/share/perl6/site/bin:/Users/ovid/bin
    PERL5LIB=lib
    PERLBREW_HOME=/Users/ovid/.perlbrew
    PERLBREW_MANPATH=/Users/ovid/perl5/perlbrew/perls/perl-5.26.2/man
    PERLBREW_PATH=/Users/ovid/perl5/perlbrew/bin:/Users/ovid/perl5/perlbrew/perls/perl-5.26.2/bin
    PERLBREW_PERL=perl-5.26.2
    PERLBREW_ROOT=/Users/ovid/perl5/perlbrew
    PERLBREW_SHELLRC_VERSION=0.84
    PERLBREW_VERSION=0.84
    PERL_BADLANG (unset)
    SHELL=/bin/bash



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About