Fcntl -w causing perl script compile failures #10616
Comments
From @toddrCreated by @toddrThis breaks: This does not: The warning message happens in the BEGIN block for sure. if I take -w out, the code does not fail. I think it's related to this comment in Fcntl.pm but I'm not sure. Perl Info
|
From @toddrThis is a 5.8.8 regression for sure /usr/bin/perl5.8.8 -w -e 'use Fcntl; print "never runs"; if(0) {my $foo = Fcntl::F_GETFL() or die};' It fails in 5.10 also |
The RT System itself - Status changed from 'new' to 'open' |
From @nwc10On Thu, Sep 09, 2010 at 12:15:24PM -0700, Todd Rinaldo wrote:
Thanks for the report. It seems to be completely unrelated to Fnctl or any external module: $ ./perl -we 'sub A () {1}; if (0) {my $foo = A}' It seems to be unrelated to constant folding: $ ./perl -cwe 'sub A () {1}; {my $foo = A or die}' Or to subroutines that inline as constants: $ ./perl -we 'my $foo = 1' I think it's because the construction is equivalent to an if: $ ./perl -Ilib -MO=Deparse -we 'my $foo = 1 or die' So, if the warning on if is desired, I'm not sure if this is a bug. Nicholas Clark |
From ebhanssen@cpan.orgOn Sat, Sep 11, 2010 at 11:29 AM, Nicholas Clark <nick@ccl4.org> wrote:
<snip>
It's not the warning that's the bug. It's the termination during Observe: eirik@bluebird[11:44:23]~$ perl5.10.1 -wle 'use Fcntl; print "used to run"; Eirik |
From @nwc10On Sat, Sep 11, 2010 at 11:46:48AM +0200, Eirik Berg Hanssen wrote:
I cannot reproduce this. This is 5.12.1: $ LD_LIBRARY_PATH=/home/nick/Perl/perl ./perl -Ilib -wle 'use Fcntl; print "used to run"; if(0) {my $foo = Fcntl::F_GETFL() or die};' Characteristics of this binary (from libperl): Nicholas Clark |
From @toddrOn Sep 12, 2010, at 4:23 AM, Nicholas Clark wrote:
My bad. My shell was chopping off the never runs string because it was missing a newline in the print. This part of the example is not an issue. Todd Rinaldo |
From @toddrOn Sep 11, 2010, at 4:29 AM, Nicholas Clark wrote:
Nicholas, thanks for the reply. To rephrase: As I understand it, This warns because putting an or next to a constant assignment is silly and potentially meant to be ==: So the issue is that Fcntl is inlining the subroutine calls into constants, which makes my $foo = Fcntl::F_GETFL() or die; inline to my $foo = 3 or die; The code in question that brought this up needed to be cross platform. I wasn't certain if Fcntl sub calls would always give sane answers for these constants and was checking their values. I guess I just need to trust that it will always return a valid constant for the given platform? Thanks, |
From @cpansproutOn Mon Sep 20 12:33:23 2010, toddr@cpanel.net wrote:
With this four-line patch: $ ./perl -we 'sub A () {1}; if (0) {my $foo = A or die}' Since the value of a constant may not be known at the time the program This just needs a test added, which I will do if this change is |
From @cpansproutInline Patch--- blead-77762.base/op.c 2010-11-18 07:11:12.000000000 -0800
+++ blead-77762-fcntl/op.c 2010-11-23 05:21:54.000000000 -0800
@@ -910,7 +910,8 @@ S_scalarboolean(pTHX_ OP *o)
PERL_ARGS_ASSERT_SCALARBOOLEAN;
- if (o->op_type == OP_SASSIGN && cBINOPo->op_first->op_type == OP_CONST) {
+ if (o->op_type == OP_SASSIGN && cBINOPo->op_first->op_type == OP_CONST
+ && !(cBINOPo->op_first->op_flags & OPf_SPECIAL)) {
if (ckWARN(WARN_SYNTAX)) {
const line_t oldline = CopLINE(PL_curcop);
diff -Nup blead-77762.base/op.h blead-77762-fcntl/op.h
--- blead-77762.base/op.h 2010-11-17 01:06:10.000000000 -0800
+++ blead-77762-fcntl/op.h 2010-11-23 04:56:39.000000000 -0800
@@ -145,6 +145,7 @@ Deprecated. Use C<GIMME_V> instead.
operand of a logical or conditional
that was optimised away, so it should
not be bound via =~ */
+ /* On OP_CONST, from a constant CV */
/* old names; don't use in new code, but don't break them, either */
#define OPf_LIST OPf_WANT_LIST
diff -Nup blead-77762.base/toke.c blead-77762-fcntl/toke.c
--- blead-77762.base/toke.c 2010-11-02 21:33:12.000000000 -0700
+++ blead-77762-fcntl/toke.c 2010-11-23 05:10:08.000000000 -0800
@@ -6509,6 +6509,7 @@ Perl_yylex(pTHX)
SvREFCNT_dec(((SVOP*)pl_yylval.opval)->op_sv);
((SVOP*)pl_yylval.opval)->op_sv = SvREFCNT_inc_simple(sv);
pl_yylval.opval->op_private = 0;
+ pl_yylval.opval->op_flags |= OPf_SPECIAL;
TOKEN(WORD);
}
|
From @cpansproutOn Sun Nov 28 13:26:15 2010, sprout wrote:
Tweaked and applied as 6b7c6d9. |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#77762 (status was 'resolved')
Searchable as RT77762$
The text was updated successfully, but these errors were encountered: