Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.96k stars 556 forks source link

PATCH: remove spurious warning from Benchmark.pm #8398

Closed p5pRT closed 18 years ago

p5pRT commented 18 years ago

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

Searchable as RT38892$

p5pRT commented 18 years ago

From perl-diddler@tlinx.org

Created by perl-diddler@tlinx.org

Whenever I use Benchmark with the "​:hireswallclock" option\, I get​:

Subroutine Benchmark​::mytime redefined at /usr/lib/perl5/5.8.8/Benchmark.pm line 459.

This happens as subroutine "mytime" is first defined as​:

  sub mytime () { time }

Then in line 459\, it is redefined as an alias of "\&Time​::HiRes​::time".

  The easiest fix is to disable warnings just before the 2nd assignment using "local $^W=0;". Then the assignment happens with no warning\, and the value of $^w immediately goes out of scope as an internal "if" block is exited.

The following is a patch to run in the same directory as Benchmark.pm. It also bumps the version number from .07 to .08

-------file Benchmark07_to_08.patch-----------------

Inline Patch ```diff --- Benchmark.pm.orig 2006-03-06 21:13:56.000000000 -0800 +++ Benchmark.pm 2006-04-10 12:24:07.803036405 -0700 @@ -435,7 +435,7 @@ clearcache clearallcache disablecache enablecache); %EXPORT_TAGS=( all => [ @EXPORT, @EXPORT_OK ] ) ; -$VERSION = 1.07; +$VERSION = 1.08; # --- ':hireswallclock' special handling @@ -456,6 +456,7 @@ my $class = shift; if (grep { $_ eq ":hireswallclock" } @_) { @_ = grep { $_ ne ":hireswallclock" } @_; + local $^W=0; *mytime = $hirestime if defined $hirestime; } Benchmark->export_to_level(1, $class, @_); -------end of patch file---------------------------- ```

I'm surprised this has gone this long without being changed -- maybe people don't run with warnings (-w) enabled when benchmarking?

Thanks\, Linda Walsh

Perl Info ``` Flags: category=install severity=none This perlbug was built using Perl v5.8.8 - Mon Mar 6 21:05:26 PST 2006 It is being executed now by Perl v5.8.8 - Mon Mar 6 20:55:27 PST 2006. Site configuration information for perl v5.8.8: Configured by perl-diddler at Mon Mar 6 20:55:27 PST 2006. Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.15.5-biglowmem-opt, archname=i686-linux uname='linux ishtar 2.6.15.5-biglowmem-opt #2 smp sun mar 5 13:14:19 pst 2006 i686 i686 i386 gnulinux ' config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr -Dinstallusrbinperl -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Duseshrplib=true -Doptimize=-O2 -march=i686 -fomit-frame-pointer -Wall -pipe -fweb -funit-at-a-time -frename-registers -fomit-frame-pointer' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2 -march=i686 -fomit-frame-pointer -Wall -pipe -fweb -funit-at-a-time -frename-registers -fomit-frame-pointer', cppflags='-fno-strict-aliasing -pipe -I/usr/local/include' ccversion='', gccversion='3.3.5 20050117 (prerelease) (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 =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.3.4' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.8/i686-linux/CORE' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Locally applied patches: @INC for perl v5.8.8: /usr/local/lib/perl/5.8 /usr/lib/perl5/5.8.8/i686-linux /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i686-linux /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i686-linux /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl . Environment for perl v5.8.8: LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=.:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/opt/gnome/bin:/opt/kde3/bin PERL5LIB=/usr/local/lib/perl/5.8 PERL_BADLANG (unset) SHELL=/bin/bash ```
p5pRT commented 18 years ago

From @smpeters

[perl-diddler@​tlinx.org - Mon Apr 10 18​:53​:45 2006]​:

This is a bug report for perl from perl-diddler@​tlinx.org\, generated with the help of perlbug 1.35 running under perl v5.8.8.

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

Whenever I use Benchmark with the "​:hireswallclock" option\, I get​:

Subroutine Benchmark​::mytime redefined at /usr/lib/perl5/5.8.8/Benchmark.pm line 459.

This happens as subroutine "mytime" is first defined as​:

sub mytime \(\) \{ time \}

Then in line 459\, it is redefined as an alias of "\&Time​::HiRes​::time".

The easiest fix is to disable warnings just before the 2nd

assignment using "local $^W=0;". Then the assignment happens with no warning\, and the value of $^w immediately goes out of scope as an internal "if" block is exited.

The following is a patch to run in the same directory as Benchmark.pm. It also bumps the version number from .07 to .08

-------file Benchmark07_to_08.patch----------------- --- Benchmark.pm.orig 2006-03-06 21​:13​:56.000000000 -0800 +++ Benchmark.pm 2006-04-10 12​:24​:07.803036405 -0700 @​@​ -435\,7 +435\,7 @​@​ clearcache clearallcache disablecache enablecache); %EXPORT_TAGS=( all => [ @​EXPORT\, @​EXPORT_OK ] ) ;

-$VERSION = 1.07; +$VERSION = 1.08;

# --- '​:hireswallclock' special handling

@​@​ -456\,6 +456\,7 @​@​ my $class = shift; if (grep { $_ eq "​:hireswallclock" } @​_) { @​_ = grep { $_ ne "​:hireswallclock" } @​_; + local $^W=0; *mytime = $hirestime if defined $hirestime; } Benchmark->export_to_level(1\, $class\, @​_); -------end of patch file----------------------------

I'm surprised this has gone this long without being changed -- maybe people don't run with warnings (-w) enabled when benchmarking?

Thanks\, Linda Walsh

This patch was applied as change #27906.

p5pRT commented 18 years ago

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

p5pRT commented 18 years ago

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