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

Fcntl -w causing perl script compile failures #10616

Closed
p5pRT opened this issue Sep 9, 2010 · 12 comments
Closed

Fcntl -w causing perl script compile failures #10616

p5pRT opened this issue Sep 9, 2010 · 12 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Sep 9, 2010

Migrated from rt.perl.org#77762 (status was 'resolved')

Searchable as RT77762$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 9, 2010

From @toddr

Created by @toddr

This breaks​:
$>perl5.12.1 -w -e 'use Fcntl; print "never runs"; if(0) {my $foo = Fcntl​::F_GETFL() or die};'
Found = in conditional, should be == at -e line 1.

This does not​:
$>perl5.12.1 -w -e 'use Fcntl; print "runs"; if(0) {my $foo = Fcntl​::F_GETFL()};'
runs

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.
# Force the constants to become inlined
BEGIN {
  XSLoader​::load 'Fcntl', $VERSION;
}

Perl Info

Flags:
   category=library
   severity=low
   module=Locale::Maketext
   Type=Patch
   PatchStatus=HasPatch

Site configuration information for perl 5.12.1:

Configured by cPanel at Mon Jun  7 11:16:28 CDT 2010.

Summary of my perl5 (revision 5 version 12 subversion 1) configuration:

 Platform:
   osname=linux, osvers=2.6.18-194.3.1.el5, archname=x86_64-linux
   uname='linux rpmb-centos-50-64bit 2.6.18-194.3.1.el5 #1 smp thu may 13 13:08:30 edt 2010 x86_64 x86_64 x86_64 gnulinux '
   config_args='-des -Darchname=x86_64-linux -Dcc=/usr/local/cpanel/bin/gcc -Dcpp=/usr/local/cpanel/bin/gcc -E -DDEBUGGING=none -Doptimize=-Os -Dusemymalloc=y -Duseshrplib=true -Duselargefiles=yes -Duseposix=true -Dhint=recommended -Duseperlio=yes -Dccflags=-I/usr/local/cpanel/include -L/usr/local/cpanel/lib64 -Wl,-rpath -Wl,/usr/local/cpanel/lib64  -Dcppflags=-I/usr/local/cpanel/include -L/usr/local/cpanel/lib64 -Dldflags=-Wl,-rpath -Wl,/usr/local/cpanel/lib64 -L/usr/local/cpanel/lib64 -Dprefix=/usr/local/cpanel -Dsiteprefix=/usr/local/cpanel -Dsitebin=/usr/local/cpanel/bin -Dsitelib=/usr/local/cpanel/lib64/perl5/site_lib -Dprivlib=/usr/local/cpanel/lib64/perl5/5.12.1 -Dotherlibdirs=/var/cpanel/perl5/lib:/usr/local/cpanel/lib64/perl5/cpanel -Dman1dir=/usr/local/cpanel/share/man/man1 -Dman3dir=/usr/local/cpanel/share/man/man3 -Dsiteman1dir=/usr/local/cpanel/share/man/man1 -Dsiteman3dir=/usr/local/cpanel/share/man/man3 -Dcf_by=cPanel -Dmyhostname=localhost -Dperladmin=root@localhost -Dcf_email=support@cpanel.net -Di_dbm=/usr/local/cpanel/include -Di_gdbm=/usr/local/cpanel/include -Di_ndbm=/usr/local/cpanel/include -Ud_dosuid -Uuserelocatableinc -Umad -Uusethreads -Uusemultiplicity -Uusesocks -Uuselongdouble -Ui_db -Aldflags=-L/usr/local/cpanel/lib64 -L/usr/lib64 -L/lib64 -lgdbm -Dlocincpth=/usr/local/cpanel/include /usr/local/include  -Acflags=-fPIC -DPIC -m64 -I/usr/local/cpanel/include -Dlibpth=/usr/local/cpanel/lib64 /usr/local/lib64 /usr/local/lib /lib64 /usr/lib64  -Duse64bitint=yes -Duse64bitall=yes'
   hint=recommended, useposix=true, d_sigaction=define
   useithreads=undef, usemultiplicity=undef
   useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
   use64bitint=define, use64bitall=define, uselongdouble=undef
   usemymalloc=y, bincompat5005=undef
 Compiler:
   cc='/usr/local/cpanel/bin/gcc', ccflags ='-I/usr/local/cpanel/include -L/usr/local/cpanel/lib64 -Wl,-rpath -Wl,/usr/local/cpanel/lib64 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/cpanel/include -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
   optimize='-Os',
   cppflags='-I/usr/local/cpanel/include -L/usr/local/cpanel/lib64 -I/usr/local/cpanel/include -L/usr/local/cpanel/lib64 -Wl,-rpath -Wl,/usr/local/cpanel/lib64 -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/cpanel/include -I/usr/local/include'
   ccversion='', gccversion='4.5.0', gccosandvers=''
   intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
   d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
   ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
   alignbytes=8, prototype=define
 Linker and Libraries:
   ld='/usr/local/cpanel/bin/gcc', ldflags ='-Wl,-rpath -Wl,/usr/local/cpanel/lib64 -L/usr/local/cpanel/lib64 -L/usr/local/cpanel/lib64 -L/usr/lib64 -L/lib64 -lgdbm -fstack-protector -L/usr/local/lib'
   libpth=/usr/local/cpanel/lib64 /usr/local/lib64 /usr/local/lib /lib64 /usr/lib64
   libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
   perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
   libc=/lib/libc-2.5.so, so=so, useshrplib=true, libperl=libperl.so
   gnulibc_version='2.5'
 Dynamic Linking:
   dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/local/cpanel/lib64/perl5/5.12.1/x86_64-linux/CORE'
   cccdlflags='-fPIC', lddlflags='-shared -Os -L/usr/local/cpanel/lib64 -L/usr/lib64 -L/lib64 -L/usr/local/lib -fstack-protector'

Locally applied patches:
   cPanel Patches


@INC for perl 5.12.1:
   /usr/local/cpanel/lib64/perl5/site_lib/x86_64-linux
   /usr/local/cpanel/lib64/perl5/site_lib
   /usr/local/cpanel/lib64/perl5/5.12.1/x86_64-linux
   /usr/local/cpanel/lib64/perl5/5.12.1
   /var/cpanel/perl5/lib
   /usr/local/cpanel/lib64/perl5/cpanel
   .


Environment for perl 5.12.1:
   HOME=/home/toddr
   LANG=en_US.UTF-8
   LANGUAGE (unset)
   LD_LIBRARY_PATH (unset)
   LOGDIR (unset)
   PATH=/usr/local/cpanel/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:
   PERL_BADLANG (unset)
   SHELL=/bin/zsh


@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 9, 2010

From @toddr

This 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};'
never runs

It fails in 5.10 also
$>/usr/bin/perl5.10.0 -w -e 'use Fcntl; print "never runs"; if(0) {my $foo = Fcntl​::F_GETFL() or
die};'
Found = in conditional, should be == at -e line 1.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 9, 2010

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

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 11, 2010

From @nwc10

On Thu, Sep 09, 2010 at 12​:15​:24PM -0700, Todd Rinaldo wrote​:

This breaks​:
$>perl5.12.1 -w -e 'use Fcntl; print "never runs"; if(0) {my $foo = Fcntl​::F_GETFL() or die};'
Found = in conditional, should be == at -e line 1.

This does not​:
$>perl5.12.1 -w -e 'use Fcntl; print "runs"; if(0) {my $foo = Fcntl​::F_GETFL()};'
runs

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.
# Force the constants to become inlined
BEGIN {
XSLoader​::load 'Fcntl', $VERSION;
}

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}'
$ ./perl -we 'sub A () {1}; if (0) {my $foo = A or die}'
Found = in conditional, should be == at -e line 1.
$

It seems to be unrelated to constant folding​:

$ ./perl -cwe 'sub A () {1}; {my $foo = A or die}'
Found = in conditional, should be == at -e line 1.
-e syntax OK
$ ./perl -cwe 'sub A () {1}; {my $foo = A}'
-e syntax OK

Or to subroutines that inline as constants​:

$ ./perl -we 'my $foo = 1'
$ ./perl -we 'my $foo = 1 or die'
Found = in conditional, should be == at -e line 1.
$

I think it's because the construction is equivalent to an if​:

$ ./perl -Ilib -MO=Deparse -we 'my $foo = 1 or die'
Found = in conditional, should be == at -e line 1.
BEGIN { $^W = 1; }
die unless my $foo = 1;
-e syntax OK

So, if the warning on if is desired, I'm not sure if this is a bug.

Nicholas Clark

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 11, 2010

From ebhanssen@cpan.org

On Sat, Sep 11, 2010 at 11​:29 AM, Nicholas Clark <nick@​ccl4.org> wrote​:

On Thu, Sep 09, 2010 at 12​:15​:24PM -0700, Todd Rinaldo wrote​:

This breaks​:
$>perl5.12.1 -w -e 'use Fcntl; print "never runs"; if(0) {my $foo =
Fcntl​::F_GETFL() or die};'
Found = in conditional, should be == at -e line 1.

  <snip>

So, if the warning on if is desired, I'm not sure if this is a bug.

  It's not the warning that's the bug. It's the termination during
compilation, as demonstrated by "never runs" not printing.

  Observe​:

eirik@​bluebird[11​:44​:23]~$ perl5.10.1 -wle 'use Fcntl; print "used to run";
if(0) {my $foo = Fcntl​::F_GETFL() or die};'
Found = in conditional, should be == at -e line 1.
used to run

Eirik

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 12, 2010

From @nwc10

On Sat, Sep 11, 2010 at 11​:46​:48AM +0200, Eirik Berg Hanssen wrote​:

On Sat, Sep 11, 2010 at 11​:29 AM, Nicholas Clark <nick@​ccl4.org> wrote​:

On Thu, Sep 09, 2010 at 12​:15​:24PM -0700, Todd Rinaldo wrote​:

This breaks​:
$>perl5.12.1 -w -e 'use Fcntl; print "never runs"; if(0) {my $foo =
Fcntl​::F_GETFL() or die};'
Found = in conditional, should be == at -e line 1.

<snip>

So, if the warning on if is desired, I'm not sure if this is a bug.

It's not the warning that's the bug. It's the termination during
compilation, as demonstrated by "never runs" not printing.

Observe​:

eirik@​bluebird[11​:44​:23]~$ perl5.10.1 -wle 'use Fcntl; print "used to run";
if(0) {my $foo = Fcntl​::F_GETFL() or die};'
Found = in conditional, should be == at -e line 1.
used to run

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};'
Found = in conditional, should be == at -e line 1.
used to run
$ LD_LIBRARY_PATH=/home/nick/Perl/perl ./perl -Ilib -VSummary of my perl5 (revision 5 version 12 subversion 1) configuration​:
  Derived from​: b85be81
  Platform​:
  osname=linux, osvers=2.6.18.8-xenu, archname=x86_64-linux
  uname='linux eris 2.6.18.8-xenu #1 smp sat oct 3 10​:27​:42 bst 2009 x86_64 gnulinux '
  config_args='-Dusedevel=y -Dcc=ccache gcc -Dld=gcc -Ubincompat5005 -Uinstallusrbinperl -Dcf_email=nick@​ccl4.org -Dperladmin=nick@​ccl4.org -Dinc_version_list= -Dinc_version_list_init=0 -Doptimize=-Os -Uusethreads -Uuse64bitall -Uusemymalloc -Duseperlio -Dprefix=/Sandpit/snap5.9.x-v5.12.1 -Uusevendorprefix -Uvendorprefix=/Sandpit/snap5.9.x-v5.12.1 -Dinstallman1dir=none -Dinstallman3dir=none -Uuserelocatableinc -Umad -Dusemymalloc=y -Duseshrplib=true -de'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=define, use64bitall=undef, uselongdouble=undef
  usemymalloc=y, bincompat5005=undef
  Compiler​:
  cc='ccache gcc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-Os',
  cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.3.2', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
  libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
  libc=/lib/libc-2.7.so, so=so, useshrplib=true, libperl=libperl.so
  gnulibc_version='2.7'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/home/nick/Sandpit/snap5.9.x-v5.12.1/lib/perl5/5.12.1/x86_64-linux/CORE'
  cccdlflags='-fPIC', lddlflags='-shared -Os -L/usr/local/lib -fstack-protector'

Characteristics of this binary (from libperl)​:
  Compile-time options​: MYMALLOC PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
  PERL_USE_DEVEL USE_64_BIT_INT USE_LARGE_FILES
  USE_PERLIO USE_PERL_ATOF
  Locally applied patches​:
  uncommitted-changes
  Built under linux
  Compiled at Sep 12 2010 10​:15​:20
  @​INC​:
  lib
  /home/nick/Sandpit/snap5.9.x-v5.12.1/lib/perl5/site_perl/5.12.1/x86_64-linux
  /home/nick/Sandpit/snap5.9.x-v5.12.1/lib/perl5/site_perl/5.12.1
  /home/nick/Sandpit/snap5.9.x-v5.12.1/lib/perl5/5.12.1/x86_64-linux
  /home/nick/Sandpit/snap5.9.x-v5.12.1/lib/perl5/5.12.1
  .

Nicholas Clark

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 20, 2010

From @toddr

On Sep 12, 2010, at 4​:23 AM, Nicholas Clark wrote​:

On Sat, Sep 11, 2010 at 11​:46​:48AM +0200, Eirik Berg Hanssen wrote​:

On Sat, Sep 11, 2010 at 11​:29 AM, Nicholas Clark <nick@​ccl4.org> wrote​:

On Thu, Sep 09, 2010 at 12​:15​:24PM -0700, Todd Rinaldo wrote​:

This breaks​:
$>perl5.12.1 -w -e 'use Fcntl; print "never runs"; if(0) {my $foo =
Fcntl​::F_GETFL() or die};'
Found = in conditional, should be == at -e line 1.

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};'
Found = in conditional, should be == at -e line 1.
used to run

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

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 20, 2010

From @toddr

On Sep 11, 2010, at 4​:29 AM, Nicholas Clark 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}'
$ ./perl -we 'sub A () {1}; if (0) {my $foo = A or die}'
Found = in conditional, should be == at -e line 1.
$

It seems to be unrelated to constant folding​:

$ ./perl -cwe 'sub A () {1}; {my $foo = A or die}'
Found = in conditional, should be == at -e line 1.
-e syntax OK
$ ./perl -cwe 'sub A () {1}; {my $foo = A}'
-e syntax OK

Or to subroutines that inline as constants​:

$ ./perl -we 'my $foo = 1'
$ ./perl -we 'my $foo = 1 or die'
Found = in conditional, should be == at -e line 1.
$

I think it's because the construction is equivalent to an if​:

$ ./perl -Ilib -MO=Deparse -we 'my $foo = 1 or die'
Found = in conditional, should be == at -e line 1.
BEGIN { $^W = 1; }
die unless my $foo = 1;
-e syntax OK

So, if the warning on if is desired, I'm not sure if this is a bug.

Nicholas Clark

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 ==​:
$ ./perl -we 'my $foo = 1 or die'
Found = in conditional, should be == at -e line 1.

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,
Todd

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 28, 2010

From @cpansprout

On Mon Sep 20 12​:33​:23 2010, toddr@​cpanel.net wrote​:

On Sep 11, 2010, at 4​:29 AM, Nicholas Clark 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}'
$ ./perl -we 'sub A () {1}; if (0) {my $foo = A or die}'
Found = in conditional, should be == at -e line 1.
$

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 ==​:
$ ./perl -we 'my $foo = 1 or die'
Found = in conditional, should be == at -e line 1.

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?

With this four-line patch​:

$ ./perl -we 'sub A () {1}; if (0) {my $foo = A or die}'
$ ./perl -we 'sub A () {1}; if (0) {my $foo = 1 or die}'
Found = in conditional, should be == at -e line 1.

Since the value of a constant may not be known at the time the program
is written, it should be perfectly acceptable to do a constant
assignment in a conditional.

This just needs a test added, which I will do if this change is
acceptable. Is it?

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 28, 2010

From @cpansprout

Inline 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);
 		    }
 
@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 30, 2010

From @cpansprout

On Sun Nov 28 13​:26​:15 2010, sprout wrote​:

On Mon Sep 20 12​:33​:23 2010, toddr@​cpanel.net wrote​:

On Sep 11, 2010, at 4​:29 AM, Nicholas Clark 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}'
$ ./perl -we 'sub A () {1}; if (0) {my $foo = A or die}'
Found = in conditional, should be == at -e line 1.
$

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 ==​:
$ ./perl -we 'my $foo = 1 or die'
Found = in conditional, should be == at -e line 1.

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?

With this four-line patch​:

$ ./perl -we 'sub A () {1}; if (0) {my $foo = A or die}'
$ ./perl -we 'sub A () {1}; if (0) {my $foo = 1 or die}'
Found = in conditional, should be == at -e line 1.

Since the value of a constant may not be known at the time the program
is written, it should be perfectly acceptable to do a constant
assignment in a conditional.

Tweaked and applied as 6b7c6d9.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Nov 30, 2010

@cpansprout - Status changed from 'open' to 'resolved'

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

Successfully merging a pull request may close this issue.

None yet
1 participant