Change 34077 by [EMAIL PROTECTED] on 2008/06/22 19:05:31

        Incorrect variable reported in uninitialized value warning.
        Ops that can return undef even for defined args, could mistakenly
        warn that the arg was undefined.

Affected files ...

... //depot/perl/sv.c#1542 edit
... //depot/perl/t/lib/warnings/9uninit#30 edit

Differences ...

==== //depot/perl/sv.c#1542 (text) ====
Index: perl/sv.c
--- perl/sv.c#1541~33854~       2008-05-18 05:40:36.000000000 -0700
+++ perl/sv.c   2008-06-22 12:05:31.000000000 -0700
@@ -12594,8 +12594,75 @@
 
     case OP_ENTEREVAL: /* could be eval $undef or $x='$undef'; eval $x */
     case OP_RV2SV:
-    case OP_CUSTOM:
-       match = 1; /* XS or custom code could trigger random warnings */
+    case OP_CUSTOM: /* XS or custom code could trigger random warnings */
+
+       /* the following ops are capable of returning PL_sv_undef even for
+        * defined arg(s) */
+
+    case OP_BACKTICK:
+    case OP_PIPE_OP:
+    case OP_FILENO:
+    case OP_BINMODE:
+    case OP_TIED:
+    case OP_GETC:
+    case OP_SYSREAD:
+    case OP_SEND:
+    case OP_IOCTL:
+    case OP_SOCKET:
+    case OP_SOCKPAIR:
+    case OP_BIND:
+    case OP_CONNECT:
+    case OP_LISTEN:
+    case OP_ACCEPT:
+    case OP_SHUTDOWN:
+    case OP_SSOCKOPT:
+    case OP_GETPEERNAME:
+    case OP_FTRREAD:
+    case OP_FTRWRITE:
+    case OP_FTREXEC:
+    case OP_FTROWNED:
+    case OP_FTEREAD:
+    case OP_FTEWRITE:
+    case OP_FTEEXEC:
+    case OP_FTEOWNED:
+    case OP_FTIS:
+    case OP_FTZERO:
+    case OP_FTSIZE:
+    case OP_FTFILE:
+    case OP_FTDIR:
+    case OP_FTLINK:
+    case OP_FTPIPE:
+    case OP_FTSOCK:
+    case OP_FTBLK:
+    case OP_FTCHR:
+    case OP_FTTTY:
+    case OP_FTSUID:
+    case OP_FTSGID:
+    case OP_FTSVTX:
+    case OP_FTTEXT:
+    case OP_FTBINARY:
+    case OP_FTMTIME:
+    case OP_FTATIME:
+    case OP_FTCTIME:
+    case OP_READLINK:
+    case OP_OPEN_DIR:
+    case OP_READDIR:
+    case OP_TELLDIR:
+    case OP_SEEKDIR:
+    case OP_REWINDDIR:
+    case OP_CLOSEDIR:
+    case OP_GMTIME:
+    case OP_ALARM:
+    case OP_SEMGET:
+    case OP_GETLOGIN:
+    case OP_UNDEF:
+    case OP_SUBSTR:
+    case OP_AEACH:
+    case OP_EACH:
+    case OP_SORT:
+    case OP_CALLER:
+    case OP_DOFILE:
+       match = 1;
        goto do_op;
 
     case OP_ENTERSUB:
@@ -12607,6 +12674,7 @@
          Need a better fix at dome point. DAPM 11/2007 */
        break;
 
+
     case OP_POS:
        /* def-ness of rval pos() is independent of the def-ness of its arg */
        if ( !(obase->op_flags & OPf_MOD))

==== //depot/perl/t/lib/warnings/9uninit#30 (text) ====
Index: perl/t/lib/warnings/9uninit
--- perl/t/lib/warnings/9uninit#29~33981~       2008-06-01 12:32:34.000000000 
-0700
+++ perl/t/lib/warnings/9uninit 2008-06-22 12:05:31.000000000 -0700
@@ -1411,3 +1411,130 @@
 Use of uninitialized value in reverse at - line 4.
 Use of uninitialized value $r1 in reverse at - line 5.
 Use of uninitialized value $r2 in reverse at - line 6.
+########
+use warnings 'uninitialized';
+#
+# ops that can return undef for defined args
+#
+my $nofile = '/no/such/file';
+my $nocmd  = '/no/such/command';
+my $v;
+$v = 1 + `$nocmd`;
+$v = 1 + qx($nocmd);
+my $f = "";
+$v = 1 + open($f, $nofile);
+# *** pipe() not tested
+$v = 1 + fileno($nofile);
+$v = 1 + binmode($nofile);
+$v = 1 + tied($nofile);
+$v = 1 + getc($nofile);
+$v = 1 + sysread($nofile, my $buf,1);
+$v = 1 + eval { send($nofile, $buf,0) };
+# *** ioctl not tested
+# *** socket not tested
+# *** socketpair not tested
+# *** bind not tested
+# *** connect not tested
+# *** listen not tested
+$v = 1 + eval { accept($fh, $nofile) };
+# *** shutdown not tested
+# *** setsockopt not tested
+# *** getpeername not tested
+$v = 1 + (-r $nofile);
+$v = 1 + (-w $nofile);
+$v = 1 + (-x $nofile);
+$v = 1 + (-o $nofile);
+$v = 1 + (-R $nofile);
+$v = 1 + (-W $nofile);
+$v = 1 + (-X $nofile);
+$v = 1 + (-O $nofile);
+$v = 1 + (-e $nofile);
+$v = 1 + (-z $nofile);
+$v = 1 + (-s $nofile);
+$v = 1 + (-f $nofile);
+$v = 1 + (-d $nofile);
+$v = 1 + (-l $nofile);
+$v = 1 + (-p $nofile);
+$v = 1 + (-S $nofile);
+$v = 1 + (-b $nofile);
+$v = 1 + (-c $nofile);
+$v = 1 + (-t $nofile);
+$v = 1 + (-u $nofile);
+$v = 1 + (-g $nofile);
+$v = 1 + (-k $nofile);
+$v = 1 + (-T $nofile);
+$v = 1 + (-B $nofile);
+$v = 1 + (-M $nofile);
+$v = 1 + (-A $nofile);
+$v = 1 + (-C $nofile);
+$v = 1 + eval { readlink $nofile };
+$v = 1 + opendir($f, $nofile);
+# *** readdir not tested
+# *** telldir not tested
+# *** seekdir not tested
+# *** rewinddir not tested
+# *** closedir not tested
+# *** gmtime not tested
+# *** alarm not tested
+# *** semget not tested
+# *** getlogin not tested
+$v = 1 + undef;
+my $x = 1; $v = 1 + undef($x);
+my $emptys = "";
+$v = 1 + substr($emptys,2,1);
+my @emptya;
+$v = 1 + each @emptya;
+my @emptyh;
+$v = 1 + each %emptyh;
+$v = 1 + sort @emptya;
+my $zero = 0; $v = 1 + caller($zero);
+$v = 1 + do $nofile;
+
+EXPECT
+Use of uninitialized value in addition (+) at - line 8.
+Use of uninitialized value in addition (+) at - line 9.
+Use of uninitialized value in addition (+) at - line 11.
+Use of uninitialized value in addition (+) at - line 13.
+Use of uninitialized value in addition (+) at - line 14.
+Use of uninitialized value in addition (+) at - line 15.
+Use of uninitialized value in addition (+) at - line 16.
+Use of uninitialized value in addition (+) at - line 17.
+Use of uninitialized value in addition (+) at - line 18.
+Use of uninitialized value in addition (+) at - line 25.
+Use of uninitialized value in addition (+) at - line 29.
+Use of uninitialized value in addition (+) at - line 30.
+Use of uninitialized value in addition (+) at - line 31.
+Use of uninitialized value in addition (+) at - line 32.
+Use of uninitialized value in addition (+) at - line 33.
+Use of uninitialized value in addition (+) at - line 34.
+Use of uninitialized value in addition (+) at - line 35.
+Use of uninitialized value in addition (+) at - line 36.
+Use of uninitialized value in addition (+) at - line 37.
+Use of uninitialized value in addition (+) at - line 38.
+Use of uninitialized value in addition (+) at - line 39.
+Use of uninitialized value in addition (+) at - line 40.
+Use of uninitialized value in addition (+) at - line 41.
+Use of uninitialized value in addition (+) at - line 42.
+Use of uninitialized value in addition (+) at - line 43.
+Use of uninitialized value in addition (+) at - line 44.
+Use of uninitialized value in addition (+) at - line 45.
+Use of uninitialized value in addition (+) at - line 46.
+Use of uninitialized value in addition (+) at - line 47.
+Use of uninitialized value in addition (+) at - line 48.
+Use of uninitialized value in addition (+) at - line 49.
+Use of uninitialized value in addition (+) at - line 50.
+Use of uninitialized value in addition (+) at - line 51.
+Use of uninitialized value in addition (+) at - line 52.
+Use of uninitialized value in addition (+) at - line 53.
+Use of uninitialized value in addition (+) at - line 54.
+Use of uninitialized value in addition (+) at - line 55.
+Use of uninitialized value in addition (+) at - line 56.
+Use of uninitialized value in addition (+) at - line 57.
+Use of uninitialized value in addition (+) at - line 67.
+Use of uninitialized value in addition (+) at - line 68.
+Use of uninitialized value in addition (+) at - line 70.
+Use of uninitialized value in addition (+) at - line 72.
+Use of uninitialized value in addition (+) at - line 74.
+Use of uninitialized value in addition (+) at - line 75.
+Use of uninitialized value in addition (+) at - line 76.
+Use of uninitialized value in addition (+) at - line 77.
End of Patch.

Reply via email to