[perl #29346] Double warning for int(undef) and abs(undef)
authorMarcus Holland-Moritz <mhx-perl@gmx.net>
Thu, 6 May 2004 17:19:17 +0000 (17:19 +0000)
committerMarcus Holland-Moritz <mhx-perl@gmx.net>
Thu, 6 May 2004 17:19:17 +0000 (17:19 +0000)
Remove the duplicate warnings and update tests.

p4raw-id: //depot/perl@22796

pp.c
t/lib/warnings/9uninit

diff --git a/pp.c b/pp.c
index 4ce7867..60eaf28 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -2800,7 +2800,9 @@ PP(pp_int)
         else preferring IV has introduced a subtle behaviour change bug. OTOH
         relying on floating point to be accurate is a bug.  */
 
-      if (SvIOK(TOPs)) {
+      if (!SvOK(TOPs))
+        SETu(0);
+      else if (SvIOK(TOPs)) {
        if (SvIsUV(TOPs)) {
            UV uv = TOPu;
            SETu(uv);
@@ -2834,7 +2836,9 @@ PP(pp_abs)
       /* This will cache the NV value if string isn't actually integer  */
       IV iv = TOPi;
 
-      if (SvIOK(TOPs)) {
+      if (!SvOK(TOPs))
+        SETu(0);
+      else if (SvIOK(TOPs)) {
        /* IVX is precise  */
        if (SvIsUV(TOPs)) {
          SETu(TOPu);   /* force it to be numeric only */
index 5bdfdb6..0c8a8d9 100644 (file)
@@ -505,8 +505,6 @@ $v = int($g1);
 $v = abs($g2);
 EXPECT
 Use of uninitialized value $g1 in int at - line 5.
-Use of uninitialized value $g1 in int at - line 5.
-Use of uninitialized value $g2 in abs at - line 6.
 Use of uninitialized value $g2 in abs at - line 6.
 ########
 use warnings 'uninitialized';