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

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

Thread Next
Henrik Tougaard
April 10, 2000 05:59
[ID 20000410.002] Prototypes defined too late - warning forrecursive subroutines
Message ID:
This is a bug report for perl from,
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. 

  $ cat
  sub fail($) {
    return 1 unless $_[0] == 1;

  fail (1);
  $ perl5.6.0 -wc  
  main::fail() called too early to check prototype at line 3. 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 syntax OK

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

  fail (1);
  $ perl5.6.0 -wc 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
FOA Trade Union for Public employees Denmark.
#include <disclaim.std>

[Please do not change anything below this line]
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:
    osname=dec_osf, osvers=4.0, archname=alpha-dec_osf
    uname='osf1 v4.0 1091 alpha '
    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
    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/, so=so, useshrplib=true,
  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:

Environment for perl v5.6.0:
    LANGUAGE (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

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