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

Empty Constants Called as Methods Return Package #7097

Closed
p5pRT opened this issue Feb 10, 2004 · 6 comments
Closed

Empty Constants Called as Methods Return Package #7097

p5pRT opened this issue Feb 10, 2004 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Feb 10, 2004

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

Searchable as RT26524$

@p5pRT
Copy link
Author

p5pRT commented Feb 10, 2004

From root@.uucp

Created by root@(none).uucp

Given this one-liner​:

  % perl -le 'use constant Foo => (); print __PACKAGE__->Foo;'
  main

Of course, it shouldn't output "main", it should output nothing. This
bug doesn't exist in 5.8.x.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.6.1:

Configured by root at Thu Sep 11 23:29:35 UTC 2003.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.4.21-1um, archname=i386-linux
    uname='linux (none) 2.4.21-1um #2 thu sep 4 18:35:37 edt 2003 i686 unknown '
    config_args='-Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.6.1 -Darchlib=/usr/lib/perl/5.6.1 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.6.1 -Dsitearch=/usr/local/lib/perl/5.6.1 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Duseshrplib -Dlibperl=libperl.so.5.6.1 -Dd_dosuid -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.4 20011002 (Debian prerelease)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -ldb -ldl -lm -lc -lcrypt
    perllibs=-ldl -lm -lc -lcrypt
    libc=/lib/libc-2.2.5.so, so=so, useshrplib=true, libperl=libperl.so.5.6.1
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.1:
    /usr/local/lib/perl/5.6.1
    /usr/local/share/perl/5.6.1
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.6.1
    /usr/share/perl/5.6.1
    /usr/local/lib/site_perl
    .


Environment for perl v5.6.1:
    HOME=/home/david
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Feb 23, 2004

From david@kineticode.com

I've now run into this bug in two installations of Perl 5.8.1. One was
with the Perl that comes with Mac OS X Panther, and the other was on
Suse. Here's the output of perl -V for the two​:

Suse​:

Summary of my perl5 (revision 5.0 version 8 subversion 1) configuration​:
  Platform​:
  osname=linux, osvers=2.6.0-test3, archname=i586-linux-thread-multi
  uname='linux g8 2.6.0-test3 #1 smp fri nov 14 00​:07​:01 utc 2003 i686
i686 i386 gnulinux '
  config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr
-Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm
-Duseshrplib=true -Doptimize=-O2 -march=i586 -mcpu=i686
-fmessage-length=0
-Wall -pipe'
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
  useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
  use64bitint=undef use64bitall=undef uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
  optimize='-O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall
-pipe',
  cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-fno-strict-aliasing'
  ccversion='', gccversion='3.3.1 (SuSE Linux)', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
  alignbytes=4, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =''
  libpth=/lib /usr/lib /usr/local/lib
  libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
  libc=, so=so, useshrplib=true, libperl=libperl.so
  gnulibc_version='2.3.2'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic
-Wl,-rpath,/usr/lib/perl5/5.8.1/i586-linux-thread-multi/CORE'
  cccdlflags='-fPIC', lddlflags='-shared'

Panther​:

Summary of my perl5 (revision 5.0 version 8 subversion 1 RC3)
configuration​:
  Platform​:
  osname=darwin, osvers=7.0, archname=darwin-thread-multi-2level
  uname='darwin hampsten 7.0 darwin kernel version 6.0​: fri jul 25
16​:58​:41 pdt 2003;
root​:xnu-344.frankd.rootsxnu-344.frankd~objrelease_ppc power macintosh
powerpc '
  config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe
-Dldflags=-Dman3ext=3pm -Duseithreads -Duseshrplib'
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
  useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
  use64bitint=undef use64bitall=undef uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-g -pipe -pipe -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -I/usr/local/include',
  optimize='-Os',
  cppflags='-no-cpp-precomp -g -pipe -pipe -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -I/usr/local/include'
  ccversion='', gccversion='3.3 20030304 (Apple Computer, Inc. build
1495)', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lc
  perllibs=-ldl -lm -lc
  libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true,
libperl=libperl.dylib
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags='-bundle -undefined dynamic_lookup
-L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Compile-time options​: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
  Locally applied patches​:
  RC3
  Built under darwin
  Compiled at Sep 12 2003 19​:50​:49
  %ENV​:
  PERL5LIB="/usr/local/bricolage/lib"
  @​INC​:
  /usr/local/bricolage/lib
  /System/Library/Perl/5.8.1/darwin-thread-multi-2level
  /System/Library/Perl/5.8.1
  /Library/Perl/5.8.1/darwin-thread-multi-2level
  /Library/Perl/5.8.1
  /Library/Perl
  /Network/Library/Perl/5.8.1/darwin-thread-multi-2level
  /Network/Library/Perl/5.8.1
  /Network/Library/Perl
  .

@p5pRT
Copy link
Author

p5pRT commented Feb 23, 2004

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

@p5pRT
Copy link
Author

p5pRT commented Feb 23, 2004

From david@kineticode.com

On Feb 23, 2004, at 3​:46 PM, Nicholas Clark wrote​:

This is rather a long explanation for a wonderfully terse report.

But thorough! I've changed my code from​:

  use constant RO_FIELDS => ();

to​:

  use RO_FIELDS () { return }

So that I should never see this problem again, anyway.

Thanks for the history, Nick--very interesting!

Regards,

David

@p5pRT
Copy link
Author

p5pRT commented Feb 24, 2004

From @nwc10

On Tue, Feb 10, 2004 at 09​:10​:24PM -0000, none via RT wrote​:

# New Ticket Created by (none)
# Please include the string​: [perl #26524]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org​:80/rt3/Ticket/Display.html?id=26524 >

This is a bug report for perl from root@​(none).uucp,
generated with the help of perlbug 1.33 running under perl v5.6.1.

-----------------------------------------------------------------
[Please enter your report here]

Thanks for this concise bug report.

Given this one-liner​:

% perl -le 'use constant Foo => (); print __PACKAGE__->Foo;'
main

Of course, it shouldn't output "main", it should output nothing. This
bug doesn't exist in 5.8.x.

Actually this isn't quite correct it does exist in 5.8.1, but not 5.8.0,
5.8.2 or 5.8.3. Consistent with what David finds​:

On Mon, Feb 23, 2004 at 01​:00​:00PM -0800, David Wheeler wrote​:

I've now run into this bug in two installations of Perl 5.8.1. One was
with the Perl that comes with Mac OS X Panther, and the other was on
Suse. Here's the output of perl -V for the two​:

I guess that the bug relates to what the return value of an empty subroutine
should return - ie

  sub empty {}

The default return from a subroutine is the last evaluated expression.

Until recently what this means for an empty sub had not been thought about,
and certainly not well defined or tested for.

Every perl version prior to 5.8.0 complied with this quite literally by
returning the last evaluated expression, so for an empty sub it returned
the last thing evaluated before the sub was called. 5.8.0 accidentally
changed this behaviour for an empty sub - empty subs returned an empty list.
However, as this change was as a side effect of fixing an unrelated bug, no
test was added to nail this new behaviour down. Hence other changes in
5.8.1 reverted the behaviour back to how 5.6.x (and earlier) have it.

After 5.8.1 was released we realised all this, consulted with Larry about
what to do, and he decided that the 5.8.0 behaviour was correct. Hence
5.8.2 went back to the 5.8.0 behaviour (with tests so that it can't change
in future). However, the particular fix for this in 5.8.2 isn't reliable
with ithreads. 5.8.3 cures this.

Although 5.6.2 was released after 5.8.2 (and Larry's decision), 5.6.2 was
only about making changes to 5.6.1 to keep it building on recent systems.
No bug fix changes were made, which is why 5.6.2 will behave the same as
5.6.1 for this code. I don't know whether a future 5.6.3 release will
change things.

This is rather a long explanation for a wonderfully terse report.

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Mar 26, 2004

@iabyn - 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
Development

No branches or pull requests

1 participant