Front page | perl.perl5.porters |
Postings from April 2015
[perl #124414] tr///r should warn in void context like s///r, only does in some cases
From:
Ævar Arnfjörð Bjarmason
Date:
April 28, 2015 16:07
Subject:
[perl #124414] tr///r should warn in void context like s///r, only does in some cases
Message ID:
rt-4.0.18-25903-1430237263-1106.124414-75-0@perl.org
# New Ticket Created by Ævar Arnfjörð Bjarmason
# Please include the string: [perl #124414]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=124414 >
This is a bug report for perl from avar@cpan.org,
generated with the help of perlbug 1.40 running under perl 5.21.12.
-----------------------------------------------------------------
[Please describe your issue here]
There's been a discrepancy in how s///r and tr///r warn ever since the
warning for tr///r was introduced in v5.13.6-354-gbb16bae.
I discovered a bug in some code today that came down to this logic
error, which doesn't warn:
$ ~/perl5/installed/bin/perl5.21.12 -wE '(my $x = "foo") =~ tr/f/b/r'
$
But the same pattern with s/// warns:
$ ~/perl5/installed/bin/perl5.21.12 -wE '(my $x = "foo") =~ s/f/b/r'
Useless use of non-destructive substitution (s///r) in void context at -e line 1.
This is an issue in blead and has been since 5.14.0 was
released. There is limited support for this warning if you write
things purely in void context:
$ ~/perl5/installed/bin/perl5.21.12 -wE 'my $x = "foo"; $x =~ s/f/b/r'
Useless use of non-destructive substitution (s///r) in void context at -e line 1.
$ ~/perl5/installed/bin/perl5.21.12 -wE 'my $x = "foo"; $x =~ tr/f/b/r'
Useless use of non-destructive transliteration (tr///r) in void context at -e line 1.
But for some reason ($x = $y) =~ s///r is considered void context by
the detection code in op.c, but ($x = $y) =~ y///r is not.
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=low
---
Site configuration information for perl 5.21.12:
Configured by avar at Tue Apr 28 15:40:55 UTC 2015.
Summary of my perl5 (revision 5 version 21 subversion 12) configuration:
Commit id: b77ebf74c6d61f12ef717fd4bd6f765479481ca1
Platform:
osname=linux, osvers=3.14-2-amd64, archname=x86_64-linux-thread-multi
uname='linux u.nix.is 3.14-2-amd64 #1 smp debian 3.14.13-2 (2014-07-24) x86_64 gnulinux '
config_args='-DDEBUGGING=both -Doptimize=-ggdb3 -Dusethreads -Dprefix=/home/avar/perl5/installed -Dusedevel -des'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-ggdb3',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
ccversion='', gccversion='4.2.1 Compatible Debian Clang 3.5.0 (tags/RELEASE_350/final)', 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/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
libs=-lpthread -lnsl -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.19'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -ggdb3 -L/usr/local/lib -fstack-protector-strong'
---
@INC for perl 5.21.12:
/home/avar/perl5/installed/lib/site_perl/5.21.12/x86_64-linux-thread-multi
/home/avar/perl5/installed/lib/site_perl/5.21.12
/home/avar/perl5/installed/lib/5.21.12/x86_64-linux-thread-multi
/home/avar/perl5/installed/lib/5.21.12
/home/avar/perl5/installed/lib/site_perl
.
---
Environment for perl 5.21.12:
HOME=/home/avar
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/home/avar/local/bin:/home/avar/perl5/installed/bin:/home/v-perlbrew/perl5/perlbrew/bin:/home/v-perlbrew/perl5/perlbrew/perls/current/bin:/home/avar/local/bin:/home/avar/g/misc-scripts:/home/avar/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
PERLDOC=-MPod::Text::Ansi
PERL_BADLANG (unset)
SHELL=/bin/bash
-
[perl #124414] tr///r should warn in void context like s///r, only does in some cases
by Ævar Arnfjörð Bjarmason