From 922c43655b68a766f6d1b8a30cddd076db7b54d7 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Thu, 6 May 2004 17:19:17 +0000 Subject: [PATCH] [perl #29346] Double warning for int(undef) and abs(undef) Remove the duplicate warnings and update tests. p4raw-id: //depot/perl@22796 --- pp.c | 8 ++++++-- t/lib/warnings/9uninit | 2 -- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pp.c b/pp.c index 4ce7867..60eaf28 100644 --- 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 */ diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit index 5bdfdb6..0c8a8d9 100644 --- a/t/lib/warnings/9uninit +++ b/t/lib/warnings/9uninit @@ -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'; -- 2.7.4