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

[perl #20850] strict report is misleading

From:
Rani Pinchuk
Date:
February 11, 2003 15:11
Subject:
[perl #20850] strict report is misleading
Message ID:
rt-20850-50863.8.7909295547702@bugs6.perl.org
# New Ticket Created by  "Rani Pinchuk" 
# Please include the string:  [perl #20850]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=20850 >


This is a bug report for perl from rani@cpan.org,
generated with the help of perlbug 1.34 running under perl v5.8.0.


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

If you run the following:

use strict;
##########
# buggy1
##########
sub buggy1 {
  my $match = shift;
  if (defined($match)) {
    nop();
    nop();
    nop();
    nop();
    nop();
  }
  elsif (defined(match)) {
  }
} # of buggy1

###############
# buggy2
###############
sub buggy2 {
   my $box = shift;
   for (my $y = 0, $y <= 10, $y++) {	
   }
} # of buggy2

###########
# nop
###########
# No OPeration
sub nop { 
} # of nop

You will get the following:

Bareword "match" not allowed while "strict subs" in use at - line 7.
Global symbol "$y" requires explicit package name at - line 23.
Global symbol "$y" requires explicit package name at - line 23.

The problems are:
1. The bareword match is not in line 7 but way lower. I guess it takes 
   the first "if" as the line it returns. But in my case, I had to look
   for very long to find where is the bare "match" variable (I had many
   elsif's...).
2. Very common mistake of me (and I guess of other programmers) is to
   put comma instead of semi-colon in the for statement. The error
   report from strict is very confusing as you see above.

Thanks,

Rani



[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl v5.8.0:

Configured by pinchuk at Mon Jan 20 23:05:19 CET 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.18-14, archname=i686-linux
    uname='linux mikush 2.4.18-14 #1 wed sep 4 13:35:50 edt 2002 i686
i686 i386 gnulinux '
    config_args=''
    hint=previous, 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 ='-DDEBUGGING -fno-strict-aliasing
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O -g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -I/usr/include/gdbm
-DDEBUGGING -fno-strict-aliasing -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -DDEBUGGING
-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/include/gdbm -DDEBUGGING -fno-strict-aliasing -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm'
    ccversion='', gccversion='3.2 20020903 (Red Hat Linux 8.0 3.2-7)',
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 -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
    libc=/lib/libc-2.2.93.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.93'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic
-Wl,-rpath,/usr/lib/perl5/5.8.0/i686-linux/CORE'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.8.0:
    /usr/lib/perl5/5.8.0/i686-linux
    /usr/lib/perl5/5.8.0
    /usr/lib/perl5/site_perl/5.8.0/i686-linux
    /usr/lib/perl5/site_perl/5.8.0
    /usr/lib/perl5/site_perl
    .

---
Environment for perl v5.8.0:
    HOME=/home/pinchuk
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_ALL=C
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
   
PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/local/pgsql/bin:/usr/local/java/bin:.:/home/pinchuk/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash







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