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
'Useless use of not in void context' should appear in more cases #9833
Comments
From @epaCreated by @epaperl -we 'not $_' perl -we 'not 1' Perl Info
|
From @rgs2009/8/17 Ed Avis <perlbug-followup@perl.org>:
That's constant-folded to 0, and the constants 0 (and 1) are $ perl -we0 |
The RT System itself - Status changed from 'new' to 'open' |
From @ikegamiOn Mon, Aug 17, 2009 at 1:21 PM, Rafael Garcia-Suarez <
It's more than that: $ perl -we'not 3' $ |
From @ikegamiOn Mon, Aug 17, 2009 at 3:07 PM, Eric Brine <ikegami@adaelis.com> wrote:
Sorry, bad example. Here's a better one, but it uses "and" instead of "not": $ perl -we'3 and 4' $ perl -we'$_ and $_' $ perl -we'3' |
From ben@morrow.me.ukQuoth ikegami@adaelis.com (Eric Brine):
It's the same. '3 and 4' is constant-folded to 0 at compile time, and 0 Ben |
From Eirik-Berg.Hanssen@allverden.noBen Morrow <ben@morrow.me.uk> writes:
Funny, '3 and 4' is not constant-folded to 0 in non-void contexts ... perl -le 'print(3 and 4); print 0+(3 and 4);' ;-) Eirik |
From @AbigailOn Mon, Aug 17, 2009 at 10:04:20PM +0200, Eirik Berg Hanssen wrote:
$ perl -MO=Deparse -wE '3 and 4; say (3 and 4)' Abigail |
From @ikegamiOn Mon, Aug 17, 2009 at 3:47 PM, Ben Morrow <ben@morrow.me.uk> wrote:
No, it gets constant-folded to 4: $ perl -MO=Concise -e'3 and 4' Are you thinking of bitwise-and (3 & 4)? |
From @ikegamiOn Mon, Aug 17, 2009 at 5:44 PM, Eric Brine <ikegami@adaelis.com> wrote:
Eric is apparently tired. It should have been constant-folded to 4, but it |
From @davidnicol
he thinks its being constant-folded to something that would |
From ben@morrow.me.ukQuoth ikegami@adaelis.com (Eric Brine):
It's me who's tired, not you. It gets constant-folded to 4, and then the What happens next is it gets caught by this piece of code in op.c: /* don't warn on optimised away booleans, eg as it seems that once constant-folding has taken place it is impossible 3 or 4; which should not warn from 3 and 4; which should. This is certainly a bug, though I'm not sure it's one Ben |
From @AbigailOn Tue, Aug 18, 2009 at 12:03:42AM +0100, Ben Morrow wrote:
Here's the '5' isn't in void context - they only thing in void context
Eh, why should C<< 3 and 4; >> warn when C<< 3 or 4; >> shouldn't? I don't Abigail |
From ben@morrow.me.ukQuoth abigail@abigail.be (Abigail):
The whole 'Foo || print' expression gets optimized to '5' before we get
OK, '3 or 4' was a bad example. It's impossible to distinguish 3 or print; which absolutely should not warn from 1 and 3; which should, since both get optimized to just '3'. Probably the second Ben |
From @davidnicolOn Mon, Aug 17, 2009 at 8:11 PM, Ben Morrow<ben@morrow.me.uk>
Trying to move warning generation before optimization rather than |
From gerard@ggoossen.netOn Tue, Aug 18, 2009 at 08:41:29AM -0500, David Nicol wrote:
My proposal to Changing the Perl 5 optree build process into an Gerard Goossen. |
Migrated from rt.perl.org#68592 (status was 'open')
Searchable as RT68592$
The text was updated successfully, but these errors were encountered: