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

[ID 20000410.002] Prototypes defined too late - warning forrecursive subroutines

Thread Next
From:
Henrik Tougaard
Date:
April 10, 2000 05:59
Subject:
[ID 20000410.002] Prototypes defined too late - warning forrecursive subroutines
Message ID:
Pine.OSF.3.95.1000410145750.22120C-100000@sula1.foa.dk
This is a bug report for perl from ht000@foa.dk,
generated with the help of perlbug 1.28 running under perl v5.6.0.

Note: Originally entered as [ID 20000327.001] but seems to have
disappeared during the perlbug update period. 

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

When running with -w flag you get a warning if a function with a
prototype is used recursively before the end of the function. 

Eg:
  $ cat fail.pl
  sub fail($) {
    return 1 unless $_[0] == 1;
    fail(4);
  }

  fail (1);
  $ perl5.6.0 -wc fail.pl  
  main::fail() called too early to check prototype at fail.pl line 3.
  fail.pl syntax OK

Perl5.005_03 does not exhibit this behaviour (possibly because the
prototype tests were not so restrictive - the warning is new anyway). 
  $ perl5.00503 -wc fail.pl
  fail.pl syntax OK

The warning can be avoided by prototyping the subroutine just before
its definition - which does look a bit silly: 
  $ cat ok.pl
  sub fail($);
  sub fail($) {
    return 1 unless $_[0] == 1;
    fail(4);
  }

  fail (1);
  $ perl5.6.0 -wc ok.pl
  ok.pl syntax OK

A more intuitive behaviour would be that the prototype is known at the
start of the subroutine block, not at the end. 

At the least a warning/note should be added in perlfunc.pod
documenting this not too intuitively clear behaviour. 

---
Henrik Tougaard    ht000@foa.dk
FOA Trade Union for Public employees Denmark.
#include <disclaim.std>

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

Configured by ht000 at Thu Mar 23 07:46:36 MET 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=dec_osf, osvers=4.0, archname=alpha-dec_osf
    uname='osf1 panama2.foa.dk v4.0 1091 alpha '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=define use64bitall=define uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O4', gccversion=
    cppflags='-std -ieee -D_INTRINSICS -I/usr/local/include -DLANGUAGE_C'
    ccflags ='-std -fprm d -ieee -D_INTRINSICS -I/usr/local/include -DLANGUAGE_C'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=8, ptrsize=8, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /var/shlib
    libs=-ldbm -ldb -lm -liconv
    libc=/usr/shlib/libc.so, so=so, useshrplib=true, libperl=libperl.so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-rpath,/tools/perl/lib/5.6.0/alpha-dec_osf/CORE'
    cccdlflags=' ', lddlflags='-shared -expect_unresolved "*" -O4 -msym -std -s -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.6.0:
    /usr/local/lib/perlmod
    /tools/perl/lib/5.6.0/alpha-dec_osf
    /tools/perl/lib/5.6.0
    /tools/perl/lib/site_perl/5.6.0/alpha-dec_osf
    /tools/perl/lib/site_perl/5.6.0
    /tools/perl/lib/site_perl/5.005/alpha-dec_osf
    /tools/perl/lib/site_perl/5.005
    /tools/perl/lib/site_perl
    .

---
Environment for perl v5.6.0:
    HOME=/usr/users/ht
    LANG=da_DK.ISO8859-1
    LANGUAGE (unset)
    LD_LIBRARY_PATH=/ingres_oa/ingres/lib:/usr/shlib
    LOGDIR (unset)
    PATH=/tools/perl/bin:/usr/local/scripts:/usr/local/bin:/usr/local:/sbin:/usr/sbin:/usr/bin:/usr/bin/X11:/usr/opt/networker/bin:/progs/CVS/cvs-1.10/bin:/usr/users/ht/bin:/ingres_oa/ingres/utility:/ingres_oa/ingres/bin
    PERL5LIB=/usr/local/lib/perlmod
    PERL_BADLANG (unset)
    SHELL=/usr/bin/ksh


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