develooper Front page | perl.perl5.porters | Postings from April 2007

[perl #42601] Inconsistent warning of redefined subroutines in Exporter

Thread Next
Colin Robertson
April 19, 2007 00:55
[perl #42601] Inconsistent warning of redefined subroutines in Exporter
Message ID:
# New Ticket Created by  Colin Robertson 
# Please include the string:  [perl #42601]
# in the subject line of all future correspondence about this issue. 
# <URL: >

Getting bounces if I send with perlbug, but that may be due to our mail
server configuration, so retrying manually:

This is a bug report for perl from,
generated with the help of perlbug 1.35 running under perl v5.8.8.

There is an odd inconsistency in the behaviour of Exporter and the
points at which it warns about redefining subroutines. Consider the
following modules:

-- --

package Foo;

use base 'Exporter';
our @EXPORT_OK = qw( foobar );

sub foobar { print "Foo\n" };


-- --

package Bar;

use base 'Exporter';
our @EXPORT_OK = qw( foobar );

sub foobar { print "Bar\n" };


-- --

package Once;

use Foo qw( foobar );
use Bar qw( foobar );


-- --

package Twice;

use Foo qw( foobar );
use Bar qw( foobar );


-- End --

Running "perl -we 'use Once;'" gives us no warnings, but running "perl
-we 'use Once; use Twice;'" gives us:

Subroutine Twice::foobar redefined at
/usr/local/lib/perl5/5.8.7/ line 65.
 at line 4

Ideally, there should have been a warning just when compiling Once.

This bug, or at least something related to it, was encountered in the
wild with code that effectively did:

use File::Temp;
use File::Slurp;

(with File::Temp version 0.16 and File::Slurp version 9999.11). This
gives us the warning:

Subroutine File::Slurp::O_RDWR redefined at
/usr/local/cps_perl5.8.7/site_perl/File/ line 7
Subroutine File::Slurp::O_CREAT redefined at
/usr/local/cps_perl5.8.7/site_perl/File/ line 7
Subroutine File::Slurp::O_EXCL redefined at
/usr/local/cps_perl5.8.7/site_perl/File/ line 7

On the other hand, when the use statements are reversed, there is no

use File::Slurp;
use File::Temp;

I think File::Slurp should actually be warning a lot, regardless of
anything else that happens, because the following lines import a bunch
of duplicated symbols:

use Fcntl qw( :DEFAULT ) ;
use POSIX qw( :fcntl_h ) ;

It happens that File::Temp makes some use of O_RDWR, O_CREAT and 0_EXCL,
which triggers the warning in File::Slurp.

Site configuration information for perl v5.8.8:

Configured by comand at Thu Mar 23 17:51:47 EST 2006.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
    osname=solaris, osvers=2.8, archname=sun4-solaris-thread-multi
    uname='sunos ra 5.8 generic_117350-28 sun4u sparc
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-D_REENTRANT -xO3 -xarch=v8 -xspace -xildoff
-I/opt/csw/bdb43/include -I/opt/csw/include -D_LARGEFILE_SOURCE
    optimize='-xO3 -xarch=v8 -xspace -xildoff',
    cppflags='-D_REENTRANT -xO3 -xarch=v8 -xspace -xildoff
-I/opt/csw/bdb43/include -I/opt/csw/include'
    ccversion='Sun C 5.7 2005/01/07', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-xarch=v8 -L/opt/csw/bdb43/lib -L/opt/csw/lib
-L/usr/lib -L/usr/ccs/lib -L/lib'
    libpth=/usr/lib /usr/ccs/lib /lib /opt/csw/lib
    libs=-lsocket -lnsl -lgdbm -ldb-4.3 -ldl -lm -lpthread -lc
    perllibs=-lsocket -lnsl -ldb-4.3 -ldl -lm -lpthread -lc
    libc=/lib/, so=so, useshrplib=true,
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-R
    cccdlflags='-KPIC', lddlflags='-G -L/opt/csw/bdb43/lib
-L/opt/csw/lib -L/usr/lib -L/usr/ccs/lib -L/lib'

Locally applied patches:

@INC for perl v5.8.8:

Environment for perl v5.8.8:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Colin Robertson
Software Engineer, Vision (Factual & Learning)
BBC Future Media & Technology
2507, White City
T: 0208 752 7295
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About