develooper Front page | perl.perl5.porters | Postings from February 2013

[perl #116681] local sub gets warning for no ref's (when it is used)

Thread Next
From:
Linda Walsh
Date:
February 7, 2013 22:42
Subject:
[perl #116681] local sub gets warning for no ref's (when it is used)
Message ID:
rt-3.6.HEAD-27190-1360276914-1228.116681-75-0@perl.org
# New Ticket Created by  Linda Walsh 
# Please include the string:  [perl #116681]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=116681 >



This is a bug report for perl from perl-diddler@tlinx.org,
generated with the help of perlbug 1.39 running under perl 5.16.1.


-----------------------------------------------------------------
[Please describe your issue here]
I'm getting an invalid waring out of this program:

perl> more ptst.pl
#!/usr/bin/perl -wl
use strict;
use 5.14.0;
{ package pkg;

  sub a() { my $p=shift;
    local * b = sub() {
      my $p=shift; 
      return "value returned from b"
    };

    my $c=$p->b();
  }
  sub new() {
    my $p=shift; my $c=ref $p || $p;
    bless $p={}, $c;
  }
  sub d() {
    my $p=shift;
    $p->a;
  }
}
package main;
  my $ref=pkg->new;
  print sprintf "d=%s", $ref->d;
perl>
perl> ptst.pl
Name "pkg::b" used only once: possible typo at ./ptst.pl line 7.
d=value returned from b

=============
At first I thought I might have an error in my prog... but I didn't
see how.  It still makes me feel uneasy -- as I wonder if it is working
by 'accident', and will change randomly in the next release or something.

So wazzup?  Bogus warning or hidden trap? ;-)


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
This perlbug was built using Perl 5.16.1 - Mon Sep 10 13:51:31 UTC 2012
It is being executed now by  Perl 5.16.1 - Mon Sep 10 13:45:59 UTC 2012.

Site configuration information for perl 5.16.1:

Configured by abuild at Mon Sep 10 13:45:59 UTC 2012.

Summary of my perl5 (revision 5 version 16 subversion 1) configuration:
   
  Platform:
    osname=linux, osvers=3.4.6-2.10-default, archname=x86_64-linux-thread-multi
    uname='linux build35 3.4.6-2.10-default #1 smp thu jul 26 09:36:26 utc 2012 (641c197) x86_64 x86_64 x86_64 gnulinux '
    config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr -Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Dd_dbm_open -Duseshrplib=true -Doptimize=-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe -Accflags=-DPERL_USE_SAFE_PUTENV -Dotherlibdirs=/usr/lib/perl5/site_perl'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -pipe',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -fstack-protector'
    ccversion='', gccversion='4.7.1 20120723 [gcc-4_7-branch revision 189773]', 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='cc', ldflags =' -L/usr/local/lib64 -fstack-protector'
    libpth=/lib64 /usr/lib64 /usr/local/lib64
    libs=-lm -ldl -lcrypt -lpthread
    perllibs=-lm -ldl -lcrypt -lpthread
    libc=/lib64/libc-2.16.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.16'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.16.1/x86_64-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib64 -fstack-protector'

Locally applied patches:
    

---
@INC for perl 5.16.1:
    /home/law/bin/lib
    /usr/lib/perl5/site_perl/5.16.1/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl/5.16.1
    /usr/lib/perl5/vendor_perl/5.16.1/x86_64-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.16.1
    /usr/lib/perl5/5.16.1/x86_64-linux-thread-multi
    /usr/lib/perl5/5.16.1
    /usr/lib/perl5/site_perl/5.16.1/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl/5.16.1
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.16.0/x86_64-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.16.0
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/site_perl
    .

---
Environment for perl 5.16.1:
    HOME=/home/law
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_COLLATE=C
    LC_CTYPE=en_US.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=.:/sbin:/usr/local/sbin:/home/law/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/opt/dell/srvadmin/bin:/usr/sbin:/etc/local/func_lib:/home/law/lib:/home/law/bin/lib:/usr/sbin
    PERL5OPT=-CSA -I/home/law/bin/lib
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About