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

C<use integer; $x += 1> gives uninitialized warning #2764

Closed
p5pRT opened this issue Oct 26, 2000 · 1 comment
Closed

C<use integer; $x += 1> gives uninitialized warning #2764

p5pRT opened this issue Oct 26, 2000 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Oct 26, 2000

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

Searchable as RT4521$

@p5pRT
Copy link
Author

p5pRT commented Oct 26, 2000

From @ysth

Created by @ysth

+= and -= give an uninitialized warning only when under use integer​:

[D​:\home\sthoenna]perl -we "$x += 1; print $x"
1
[D​:\home\sthoenna]perl -we "$x -= 1; print $x"
-1
[D​:\home\sthoenna]perl -we "use integer; $x += 1; print $x"
Use of uninitialized value in integer addition (+) at -e line 1.
1
[D​:\home\sthoenna]perl -we "use integer; $x -= 1; print $x"
Use of uninitialized value in integer subtraction (-) at -e line 1.
-1

--, ++, +=, -=, |=, and ^= are supposed to not give this warning.

Patch (to 7348)​:

Inline Patch
--- pp.c.orig	Sun Oct 15 19:21:44 2000
+++ pp.c	Thu Oct 26 11:23:48 2000
@@ -1566,7 +1566,7 @@
 {
     djSP; dATARGET; tryAMAGICbin(add,opASSIGN);
     {
-      dPOPTOPiirl;
+      dPOPTOPiirl_ul;
       SETi( left + right );
       RETURN;
     }
@@ -1576,7 +1576,7 @@
 {
     djSP; dATARGET; tryAMAGICbin(subtr,opASSIGN);
     {
-      dPOPTOPiirl;
+      dPOPTOPiirl_ul;
       SETi( left - right );
       RETURN;
     }
--- t/op/assignwarn.t.orig	Thu Sep 14 19:55:14 2000
+++ t/op/assignwarn.t	Thu Oct 26 13:53:40 2000
@@ -21,7 +21,7 @@
 
 sub uninitialized { $warn =~ s/Use of uninitialized value[^\n]+\n//s; }
     
-print "1..23\n";
+print "1..32\n";
 
 { my $x; $x ++;     ok  1, ! uninitialized; }
 { my $x; $x --;     ok  2, ! uninitialized; }
@@ -55,7 +55,19 @@
 { my $x; $x |= "x"; ok 21, ! uninitialized; }
 { my $x; $x ^= "x"; ok 22, ! uninitialized; }
 
-ok 23, $warn eq '';
+{ use integer; my $x; $x += 1; ok 23, ! uninitialized; }
+{ use integer; my $x; $x -= 1; ok 24, ! uninitialized; }
+
+{ use integer; my $x; $x *= 1; ok 25,  uninitialized; }
+{ use integer; my $x; $x /= 1; ok 26,  uninitialized; }
+{ use integer; my $x; $x %= 1; ok 27,  uninitialized; }
+
+{ use integer; my $x; $x ++;   ok 28, ! uninitialized; }
+{ use integer; my $x; $x --;   ok 29, ! uninitialized; }
+{ use integer; my $x; ++ $x;   ok 30, ! uninitialized; }
+{ use integer; my $x; -- $x;   ok 31, ! uninitialized; }
+
+ok 32, $warn eq '';
 
 # If we got any errors that we were not expecting, then print them
 print map "#$_\n", split /\n/, $warn if length $warn;
Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.7.0:

Configured by sthoenna at Tue Oct 17 22:38:09 PDT 2000.

Summary of my perl5 (revision 5.0 version 7 subversion 0) configuration:
  Platform:
    osname=os2, osvers=2.30, archname=os2-64int-ld
    uname='os2 efn.org 2 2.30 i386  '
    config_args='-de -Dprefix=d:/perl -Dusedevel -Duse64bitint -Duselongdouble -Aoptimize=-DDEBUGGING'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=define
  Compiler:
    cc='gcc', ccflags ='-Zomf -Zmt -DDOSISH -DOS2=2 -DEMBED -I. -D_EMX_CRT_REV_=63',
    optimize='-O2 -fomit-frame-pointer -malign-loops=2 -malign-jumps=2 -malign-functions=2 -s -DDEBUGGING',
    cppflags='-Zomf -Zmt -DDOSISH -DOS2=2 -DEMBED -I. -D_EMX_CRT_REV_=63'
    ccversion='', gccversion='2.8.1', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='long double', nvsize=12, Off_t='off_t', lseeksize=4
    alignbytes=4, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags ='-Zexe -Zomf -Zmt -Zcrtdll -Zstack 32000'
    libpth=d:/emx/lib d:/emx/lib/mt
    libs=-lsocket -lm -lbsd
    perllibs=-lsocket -lm -lbsd
    libc=d:/emx/lib/mt/c_import.lib, so=dll, useshrplib=true, libperl=libperl.lib
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-Zdll', lddlflags='-Zdll -Zomf -Zmt -Zcrtdll -s'

Locally applied patches:
    DEVEL7347


@INC for perl v5.7.0:
    lib
    d:/perl/lib/5.7.0/os2-64int-ld
    d:/perl/lib/5.7.0
    d:/perl/lib/site_perl/5.7.0/os2-64int-ld
    d:/perl/lib/site_perl/5.7.0
    d:/perl/lib/site_perl
    .


Environment for perl v5.7.0:
    HOME=d:\home\sthoenna
    LANG=en_us
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR=sthoenna
    PATH=d:\bin;C:\OS2;d:\perl\bin;C:\OS2\SYSTEM;C:\OS2\INSTALL;C:\;C:\OS2\MDOS;C:\OS2\APPS;C:\MMOS2;d:\os2apps\util;d:\DOSAPPS\UTIL;c:\sio;D:\WINDOWS;d:\pdksh;d:\emx\bin;d:\emacs\19.33\bin;d:\ispell
    PERL_BADLANG (unset)
    PERL_SH_DIR=d:\BIN
    SHELL (unset)


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