Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

surprising precedence issue: sort f()->@* #16665

Open
p5pRT opened this issue Aug 21, 2018 · 4 comments
Open

surprising precedence issue: sort f()->@* #16665

p5pRT opened this issue Aug 21, 2018 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 21, 2018

Migrated from rt.perl.org#133464 (status was 'open')

Searchable as RT133464$

@p5pRT
Copy link
Author

p5pRT commented Aug 21, 2018

From jeremyhetzler@gmail.com

Created by jeremyhetzler@gmail.com

If sort() is called without parens and passed a function call with postfix
derefence, sort() processes the function's return value prior to the
dereference. This is contrary to expectation and to the behavior of other
builtin functions. In addition, postfix dereference behaves differently here
from circumfix dereference, which is contrary to the docs.

Example​:

  $ /bin/perl -we'sub f {[1,2,3]}; print sort f()->@​*'
  Use of uninitialized value in array dereference at -e line 1.

Expected behavior would be the same as​:

  $ /bin/perl -we'sub f {[1,2,3]}; print sort @​{f()}'
  123

From perlref​:

  Postfix dereference should work in all circumstances where block
  (circumfix) dereference worked, and should be entirely equivalent.

Suggestions​:

- Change the parser so that "sort f()->@​*" is equivalent to "sort @​{f()}".

- If the parser can't be changed, issue a warning in this situation
  with a suggested workaround.

Thanks!

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.26.2:

Configured by ASSI at Mon Apr 16 19:45:26 CEST 2018.

Summary of my perl5 (revision 5 version 26 subversion 2) configuration:

  Platform:
    osname=cygwin
    osvers=2.10.0(0.32553)
    archname=x86_64-cygwin-threads-multi
    uname='cygwin_nt-6.3 cygwin 2.10.0(0.32553) 2018-02-02 15:16 x86_64 cygwin '
    config_args='-des -Dprefix=/usr -Dmksymlinks
-Darchname=x86_64-cygwin-threads -Dlibperl=cygperl5_26.dll -Dcc=gcc
-Dld=g++ -Accflags=-ggdb -O2 -pipe -Wall -Werror=format-security
-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.26.2-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.26.2=/usr/src/debug/perl-5.26.2-1
-fwrapv'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags ='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE
-ggdb -O2 -pipe -Wall -Werror=format-security -D_FORTIFY_SOURCE=2
-fstack-protector-strong --param=ssp-buffer-size=4
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.26.2-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.26.2=/usr/src/debug/perl-5.26.2-1
-fwrapv -fno-strict-aliasing'
    optimize='-O3'
    cppflags='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE
-ggdb -O2 -pipe -Wall -Werror=format-security -D_FORTIFY_SOURCE=2
-fstack-protector-strong --param=ssp-buffer-size=4
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.26.2-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.26.2=/usr/src/debug/perl-5.26.2-1
-fwrapv -fno-strict-aliasing'
    ccversion=''
    gccversion='6.4.0'
    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='g++'
    ldflags =' -Wl,--enable-auto-import -Wl,--export-all-symbols
-Wl,--enable-auto-image-base -fstack-protector-strong'
    libpth=/usr/lib
    libs=-lpthread -lgdbm -ldb -ldl -lcrypt -lgdbm_compat
    perllibs=-lpthread -ldl -lcrypt
    libc=/usr/lib/libcygwin.a
    so=dll
    useshrplib=true
    libperl=cygperl5_26.dll
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' --shared  -Wl,--enable-auto-import
-Wl,--export-all-symbols -Wl,--enable-auto-image-base
-fstack-protector-strong'

Locally applied patches:
    Cygwin: README
    Cygwin: use auto-image-base instead of fixed DLL base address
    Cygwin: modify hints
    Cygwin: Configure correct libsearch
    Cygwin: Configure correct libpth
    Cygwin: Win32 correct UTF8 handling
    Perl: File-Path-2.14 (fixes CVE2017-6512)


@INC for perl 5.26.2:
    /home/jhetzler/lib/perl
    lib
    /usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads
    /usr/local/share/perl5/site_perl/5.26
    /usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads
    /usr/share/perl5/vendor_perl/5.26
    /usr/lib/perl5/5.26/x86_64-cygwin-threads
    /usr/share/perl5/5.26


Environment for perl 5.26.2:
    HOME=/home/jhetzler
    LANG=C.UTF-8
    LANGUAGE (unset)
    LC_COLLATE=C
    LD_LIBRARY_PATH (unset)
    LOGDIR=/home/jhetzler/log
    PATH=/usr/local/bin:/usr/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program
Files (x86)/Common Files/Acronis/SnapAPI:/cygdrive/c/Program Files
(x86)/Common Files/Crystal Decisions/2.5/Bin:/cygdrive/c/Program
Files/StorageCraft/GRE:/cygdrive/c/Program
Files/StorageCraft/GRE/axis2c/lib:/cygdrive/c/Program Files
(x86)/PuTTY:/cygdrive/c/users/jhetzler/cyghome/scripts:/usr/games:/cygdrive/c/google_appengine:/cygdrive/c/Windows/System32
    PERL5LIB=/home/jhetzler/lib/perl:lib
    PERLDOC=-otext
    PERLIO=perlio
    PERL_BADLANG (unset)
    SHELL=/usr/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 24, 2018

From @Grinnz

Probably related to​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133178,
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=130178,
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=3629

-Dan

On Fri, Aug 24, 2018 at 11​:04 AM Jeremy Hetzler (via RT) <
perlbug-followup@​perl.org> wrote​:

# New Ticket Created by Jeremy Hetzler
# Please include the string​: [perl #133464]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133464 >

This is a bug report for perl from jeremyhetzler@​gmail.com,
generated with the help of perlbug 1.40 running under perl 5.26.2.

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

If sort() is called without parens and passed a function call with postfix
derefence, sort() processes the function's return value prior to the
dereference. This is contrary to expectation and to the behavior of other
builtin functions. In addition, postfix dereference behaves differently
here
from circumfix dereference, which is contrary to the docs.

Example​:

$ /bin/perl -we'sub f {[1,2,3]}; print sort f()->@​*'
Use of uninitialized value in array dereference at -e line 1.

Expected behavior would be the same as​:

$ /bin/perl -we'sub f {[1,2,3]}; print sort @​{f()}'
123

From perlref​:

Postfix dereference should work in all circumstances where block
(circumfix) dereference worked, and should be entirely equivalent.

Suggestions​:

- Change the parser so that "sort f()->@​*" is equivalent to "sort @​{f()}".

- If the parser can't be changed, issue a warning in this situation
with a suggested workaround.

Thanks!

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

Configured by ASSI at Mon Apr 16 19​:45​:26 CEST 2018.

Summary of my perl5 (revision 5 version 26 subversion 2) configuration​:

Platform​:
osname=cygwin
osvers=2.10.0(0.32553)
archname=x86_64-cygwin-threads-multi
uname='cygwin_nt-6.3 cygwin 2.10.0(0.32553) 2018-02-02 15​:16 x86_64
cygwin '
config_args='-des -Dprefix=/usr -Dmksymlinks
-Darchname=x86_64-cygwin-threads -Dlibperl=cygperl5_26.dll -Dcc=gcc
-Dld=g++ -Accflags=-ggdb -O2 -pipe -Wall -Werror=format-security
-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4

-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.26.2-1

-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.26.2=/usr/src/debug/perl-5.26.2-1
-fwrapv'
hint=recommended
useposix=true
d_sigaction=define
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=define
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
bincompat5005=undef
Compiler​:
cc='gcc'
ccflags ='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE
-ggdb -O2 -pipe -Wall -Werror=format-security -D_FORTIFY_SOURCE=2
-fstack-protector-strong --param=ssp-buffer-size=4

-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.26.2-1

-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.26.2=/usr/src/debug/perl-5.26.2-1
-fwrapv -fno-strict-aliasing'
optimize='-O3'
cppflags='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE
-ggdb -O2 -pipe -Wall -Werror=format-security -D_FORTIFY_SOURCE=2
-fstack-protector-strong --param=ssp-buffer-size=4

-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.26.2-1

-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.26.2=/usr/src/debug/perl-5.26.2-1
-fwrapv -fno-strict-aliasing'
ccversion=''
gccversion='6.4.0'
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='g++'
ldflags =' -Wl,--enable-auto-import -Wl,--export-all-symbols
-Wl,--enable-auto-image-base -fstack-protector-strong'
libpth=/usr/lib
libs=-lpthread -lgdbm -ldb -ldl -lcrypt -lgdbm_compat
perllibs=-lpthread -ldl -lcrypt
libc=/usr/lib/libcygwin.a
so=dll
useshrplib=true
libperl=cygperl5_26.dll
gnulibc_version=''
Dynamic Linking​:
dlsrc=dl_dlopen.xs
dlext=dll
d_dlsymun=undef
ccdlflags=' '
cccdlflags=' '
lddlflags=' --shared -Wl,--enable-auto-import
-Wl,--export-all-symbols -Wl,--enable-auto-image-base
-fstack-protector-strong'

Locally applied patches​:
Cygwin​: README
Cygwin​: use auto-image-base instead of fixed DLL base address
Cygwin​: modify hints
Cygwin​: Configure correct libsearch
Cygwin​: Configure correct libpth
Cygwin​: Win32 correct UTF8 handling
Perl​: File-Path-2.14 (fixes CVE2017-6512)

---
@​INC for perl 5.26.2​:
/home/jhetzler/lib/perl
lib
/usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads
/usr/local/share/perl5/site_perl/5.26
/usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads
/usr/share/perl5/vendor_perl/5.26
/usr/lib/perl5/5.26/x86_64-cygwin-threads
/usr/share/perl5/5.26

---
Environment for perl 5.26.2​:
HOME=/home/jhetzler
LANG=C.UTF-8
LANGUAGE (unset)
LC_COLLATE=C
LD_LIBRARY_PATH (unset)
LOGDIR=/home/jhetzler/log

PATH=/usr/local/bin​:/usr/bin​:/cygdrive/c/Windows/system32​:/cygdrive/c/Windows​:/cygdrive/c/Windows/System32/Wbem​:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0​:/cygdrive/c/Program
Files (x86)/Common Files/Acronis/SnapAPI​:/cygdrive/c/Program Files
(x86)/Common Files/Crystal Decisions/2.5/Bin​:/cygdrive/c/Program
Files/StorageCraft/GRE​:/cygdrive/c/Program
Files/StorageCraft/GRE/axis2c/lib​:/cygdrive/c/Program Files

(x86)/PuTTY​:/cygdrive/c/users/jhetzler/cyghome/scripts​:/usr/games​:/cygdrive/c/google_appengine​:/cygdrive/c/Windows/System32
PERL5LIB=/home/jhetzler/lib/perl​:lib
PERLDOC=-otext
PERLIO=perlio
PERL_BADLANG (unset)
SHELL=/usr/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 24, 2018

The RT System itself - Status changed from 'new' to 'open'

@Grinnz
Copy link
Contributor

Grinnz commented Oct 21, 2019

For GitHub links, the corresponding issues are: #16548, #15733, #2305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants