Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Use of uninitialized value" reported on incorrect line number #4061

Closed
p5pRT opened this issue Jun 4, 2001 · 2 comments
Closed

"Use of uninitialized value" reported on incorrect line number #4061

p5pRT opened this issue Jun 4, 2001 · 2 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Jun 4, 2001

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

Searchable as RT7084$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jun 4, 2001

From lecates@laurelnetworks.com

-----------------------------------------------------------------
The line number reported for "Use of uninitialized value" is wrong
under certain conditions. The script below reports this error​:
  Use of uninitialized value at /u/lecates/src/diag1/p1 line 5.
The error disappears if an extra statement is added at the "HERE" points.
This problem also occurs if the error is in the "else" portion of a
conditional statement. In all cases, the first line of the statement
is reported as the error, instead of the actual line number. I suspect
that the optimizer may be at fault. Thanks for investigating!

-Roy

BEGIN
#! /usr/bin/perl -w
use strict;
my $pass;

if (1) {

  unless ($pass == 1) {
  exit;
  # HERE
  }
  # HERE
}

END

Perl Info


Site configuration information for perl 5.00503:

Configured by root at Mon Aug 30 23:08:56 EDT 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.2.5-22smp, archname=i386-linux
    uname='linux porky.devel.redhat.com 2.2.5-22smp #1 smp wed jun 2 09:11:51 edt 1999 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lposix -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00503:
    /usr/lib/perl5/5.00503/i386-linux
    /usr/lib/perl5/5.00503
    /usr/lib/perl5/site_perl/5.005/i386-linux
    /usr/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00503:
    HOME=/u/lecates
    LANG=en_US
    LANGUAGE (unset)
    LC_ALL=en_US
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/bin:/bin:/usr/X11R6/bin:/usr/local/bin:/opt/bin:/usr/X11R6/bin:.
    PERL_BADLANG (unset)
    SHELL=/bin/csh

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jun 4, 2001

From [Unknown Contact. See original ticket]

The line number reported for "Use of uninitialized value" is wrong
under certain conditions. The script below reports this error​:
Use of uninitialized value at /u/lecates/src/diag1/p1 line 5.
The error disappears if an extra statement is added at the "HERE" points.

The problem is due to Perl's optimization of​:

  if (TRUE_CONSTANT) {
  ONE_STATEMENT_OR_BLOCK;
  }

to

  ONE_STATEMENT_OR_BLOCK;

And apparently, in your case, the optimization

  if (COND) { EXPR; }

to

  COND and EXPR;

This turns your code into​:

  #!/usr/bin/perl -w
  use strict;
  my $pass;

  $pass == 1 or exit;

If you add a statement to the if-statement or the unless-statement, the
optimization doesn't occur as such.

--
Jeff "japhy" Pinyan japhy@​pobox.com http​://www.pobox.com/~japhy/
Eruséro Marillion -- wielder of Ringril, known as Hesinaur, the Winter-Sun
Are you a Monk? http​://www.perlmonks.com/ http​://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http​://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant