Skip Menu |
Report information
Id: 132908
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: perl [at] ton.iguana.be
Cc:
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: medium
Type: core
Perl Version: 5.20.2
Fixed In: (no value)



Subject: String/Number interpretation of a string
From: perl [...] ton.iguana.be
Date: Sun, 25 Feb 2018 19:24:38 +0100
To: perlbug [...] perl.org
CC: perl [...] ton.iguana.be
Download (untitled) / with headers
text/plain 16.3k

Message body is not shown because it is too large.

RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.7k
On Sun, 25 Feb 2018 18:25:19 GMT, perl@ton.iguana.be wrote: Show quoted text
> > This is a bug report for perl from perl@ton.iguana.be, > generated with the help of perlbug 1.40 running under perl 5.20.2. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > perl -wlE '$_="-4-5"; say -$_|0' > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > 4 > > perl -wlE '$_=-4 . -5; say -$_|0' > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > 4 > > perl -wlE '$_="-4-5"; $_+0; say -$_|0' > Useless use of addition (+) in void context at -e line 1. > Argument "-4-5" isn't numeric in addition (+) at -e line 1. > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > 4 > > perl -wlE '$_=-4 . -5; $_+0; say -$_|0' > Useless use of addition (+) in void context at -e line 1. > Argument "-4-5" isn't numeric in addition (+) at -e line 1. > 18446744073709551612 > > That last one is very unexpected. > The same thing happens on perl 5.26.1 >
I do not get the same results as you. ##### $ perl -v | head -2 | tail -1 This is perl 5, version 20, subversion 3 (v5.20.3) built for x86_64-linux $ perl -wlE '$_="-4 . -5"; $_+0; say -$_|0' Useless use of addition (+) in void context at -e line 1. Argument "-4 . -5" isn't numeric in addition (+) at -e line 1. Argument "+4 . -5" isn't numeric in bitwise or (|) at -e line 1. 4 $ perl -v | head -2 | tail -1 This is perl 5, version 26, subversion 0 (v5.26.0) built for x86_64-linux $ perl -wlE '$_="-4 . -5"; $_+0; say -$_|0' Useless use of addition (+) in void context at -e line 1. Argument "-4 . -5" isn't numeric in addition (+) at -e line 1. Argument "+4 . -5" isn't numeric in bitwise or (|) at -e line 1. 4 ##### Thank you very much. -- James E Keenan (jkeenan@cpan.org)
From: Dave Mitchell <davem [...] iabyn.com>
CC: perl5-porters [...] perl.org
Date: Mon, 26 Feb 2018 09:12:41 +0000
Subject: Re: [perl #132908] String/Number interpretation of a string
To: James E Keenan via RT <perlbug-followup [...] perl.org>
On Sun, Feb 25, 2018 at 02:10:41PM -0800, James E Keenan via RT wrote: Show quoted text
> > perl -wlE '$_="-4-5"; $_+0; say -$_|0' > > Useless use of addition (+) in void context at -e line 1. > > Argument "-4-5" isn't numeric in addition (+) at -e line 1. > > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > > 4 > > > > perl -wlE '$_=-4 . -5; $_+0; say -$_|0' > > Useless use of addition (+) in void context at -e line 1. > > Argument "-4-5" isn't numeric in addition (+) at -e line 1. > > 18446744073709551612
In the first example, $_="-4-5", $_ uses COW to share the string buffer of the constant string; in $_=-4 . -5, the expression stops $_ being COW (even though the expression is constant folded). When the string is used in numeric context, its pIOK and pNOK flags get set. However, the result of the expression -$_ only has its pIOK and pNOK flags set in the non-COW case. I haven't looked any further yet at why that is. -- Red sky at night - gerroff my land! Red sky at morning - gerroff my land! -- old farmers' sayings #14
CC: "OtherRecipients of perl Ticket #132908": ;, perl5-porters [...] perl.org
Subject: Re: [perl #132908] String/Number interpretation of a string
Date: Mon, 26 Feb 2018 12:43:23 +0100
To: James E Keenan via RT <perlbug-followup [...] perl.org>
From: Abigail <abigail [...] abigail.be>
Download (untitled) / with headers
text/plain 2.1k
On Sun, Feb 25, 2018 at 02:10:41PM -0800, James E Keenan via RT wrote: Show quoted text
> On Sun, 25 Feb 2018 18:25:19 GMT, perl@ton.iguana.be wrote:
> > > > This is a bug report for perl from perl@ton.iguana.be, > > generated with the help of perlbug 1.40 running under perl 5.20.2. > > > > > > ----------------------------------------------------------------- > > [Please describe your issue here] > > > > perl -wlE '$_="-4-5"; say -$_|0' > > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > > 4 > > > > perl -wlE '$_=-4 . -5; say -$_|0' > > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > > 4 > > > > perl -wlE '$_="-4-5"; $_+0; say -$_|0' > > Useless use of addition (+) in void context at -e line 1. > > Argument "-4-5" isn't numeric in addition (+) at -e line 1. > > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > > 4 > > > > perl -wlE '$_=-4 . -5; $_+0; say -$_|0' > > Useless use of addition (+) in void context at -e line 1. > > Argument "-4-5" isn't numeric in addition (+) at -e line 1. > > 18446744073709551612 > > > > That last one is very unexpected. > > The same thing happens on perl 5.26.1 > >
> > I do not get the same results as you.
Is that because you're using different code, or because of something else? Show quoted text
> > ##### > $ perl -v | head -2 | tail -1 > This is perl 5, version 20, subversion 3 (v5.20.3) built for x86_64-linux > > $ perl -wlE '$_="-4 . -5"; $_+0; say -$_|0'
That's not the same as written in the bug report: Show quoted text
> > perl -wlE '$_=-4 . -5; $_+0; say -$_|0'
Note the absense of quotes around C<< -4 . -5 >> in the report, while your code puts quotes there. Show quoted text
> Useless use of addition (+) in void context at -e line 1. > Argument "-4 . -5" isn't numeric in addition (+) at -e line 1. > Argument "+4 . -5" isn't numeric in bitwise or (|) at -e line 1. > 4 > > $ perl -v | head -2 | tail -1 > This is perl 5, version 26, subversion 0 (v5.26.0) built for x86_64-linux > > $ perl -wlE '$_="-4 . -5"; $_+0; say -$_|0' > Useless use of addition (+) in void context at -e line 1. > Argument "-4 . -5" isn't numeric in addition (+) at -e line 1. > Argument "+4 . -5" isn't numeric in bitwise or (|) at -e line 1. > 4
Abigail
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 2.4k
On Mon, 26 Feb 2018 11:39:05 GMT, abigail@abigail.be wrote: Show quoted text
> On Sun, Feb 25, 2018 at 02:10:41PM -0800, James E Keenan via RT wrote:
> > On Sun, 25 Feb 2018 18:25:19 GMT, perl@ton.iguana.be wrote:
> > > > > > This is a bug report for perl from perl@ton.iguana.be, > > > generated with the help of perlbug 1.40 running under perl 5.20.2. > > > > > > > > > ----------------------------------------------------------------- > > > [Please describe your issue here] > > > > > > perl -wlE '$_="-4-5"; say -$_|0' > > > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > > > 4 > > > > > > perl -wlE '$_=-4 . -5; say -$_|0' > > > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > > > 4 > > > > > > perl -wlE '$_="-4-5"; $_+0; say -$_|0' > > > Useless use of addition (+) in void context at -e line 1. > > > Argument "-4-5" isn't numeric in addition (+) at -e line 1. > > > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > > > 4 > > > > > > perl -wlE '$_=-4 . -5; $_+0; say -$_|0' > > > Useless use of addition (+) in void context at -e line 1. > > > Argument "-4-5" isn't numeric in addition (+) at -e line 1. > > > 18446744073709551612 > > > > > > That last one is very unexpected. > > > The same thing happens on perl 5.26.1 > > >
> > > > I do not get the same results as you.
> > > Is that because you're using different code, or because of something else? > >
> > > > ##### > > $ perl -v | head -2 | tail -1 > > This is perl 5, version 20, subversion 3 (v5.20.3) built for x86_64-linux > > > > $ perl -wlE '$_="-4 . -5"; $_+0; say -$_|0'
> > That's not the same as written in the bug report: >
> > > perl -wlE '$_=-4 . -5; $_+0; say -$_|0'
> > Note the absense of quotes around C<< -4 . -5 >> in the report, > while your code puts quotes there. >
You are correct. Please ignore my previous post. Show quoted text
> > Useless use of addition (+) in void context at -e line 1. > > Argument "-4 . -5" isn't numeric in addition (+) at -e line 1. > > Argument "+4 . -5" isn't numeric in bitwise or (|) at -e line 1. > > 4 > > > > $ perl -v | head -2 | tail -1 > > This is perl 5, version 26, subversion 0 (v5.26.0) built for x86_64-linux > > > > $ perl -wlE '$_="-4 . -5"; $_+0; say -$_|0' > > Useless use of addition (+) in void context at -e line 1. > > Argument "-4 . -5" isn't numeric in addition (+) at -e line 1. > > Argument "+4 . -5" isn't numeric in bitwise or (|) at -e line 1. > > 4
> > > > Abigail
Thank you very much. -- James E Keenan (jkeenan@cpan.org)
To: perl5-porters [...] perl.org
Subject: Re: [perl #132908] String/Number interpretation of a string
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
Date: Mon, 26 Feb 2018 15:09:52 +0100
Download (untitled) / with headers
text/plain 1.7k
On Sun, 25 Feb 2018 10:25:19 -0800, "perl@ton.iguana.be (via RT)" <perlbug-followup@perl.org> wrote: Show quoted text
> perl -wlE '$_="-4-5"; say -$_|0' > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > 4 > > perl -wlE '$_=-4 . -5; say -$_|0' > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > 4 > > perl -wlE '$_="-4-5"; $_+0; say -$_|0' > Useless use of addition (+) in void context at -e line 1. > Argument "-4-5" isn't numeric in addition (+) at -e line 1. > Argument "+4-5" isn't numeric in bitwise or (|) at -e line 1. > 4 > > perl -wlE '$_=-4 . -5; $_+0; say -$_|0' > Useless use of addition (+) in void context at -e line 1. > Argument "-4-5" isn't numeric in addition (+) at -e line 1. > 18446744073709551612 > > That last one is very unexpected. > The same thing happens on perl 5.26.1
Step-by-step on the last one ... $ perl -MDP -wE'$_ = -4 . -5;DDump$_;$_+0;DDump$_;say $_|0;DDump$_' Useless use of addition (+) in void context at -e line 1. SV = PV(0x24679f0) at 0x24b0ab0 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x24839f0 "-4-5"\0 CUR = 4 LEN = 10 Argument "-4-5" isn't numeric in addition (+) at -e line 1. SV = PVNV(0x370b100) at 0x24b0ab0 REFCNT = 1 FLAGS = (POK,pIOK,pNOK,pPOK) IV = -4 NV = -4 PV = 0x24839f0 "-4-5"\0 CUR = 4 LEN = 10 18446744073709551612 SV = PVNV(0x370b100) at 0x24b0ab0 REFCNT = 1 FLAGS = (POK,pIOK,pNOK,pPOK) IV = -4 NV = -4 PV = 0x24839f0 "-4-5"\0 CUR = 4 LEN = 10 -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using perl5.00307 .. 5.27 porting perl5 on HP-UX, AIX, and openSUSE http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Download (untitled)
application/pgp-signature 473b

Message body not shown because it is not plain text.



This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org