From: Dave Mitchell Date: Thu, 18 Mar 2004 14:13:16 +0000 (+0000) Subject: make ~$x give warning is $x isn't initialised. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a1afd1046e98b52e81720705c71449e6a5438e69;p=p5sagit%2Fp5-mst-13.2.git make ~$x give warning is $x isn't initialised. Also add test for uninitialised warning in & op. p4raw-id: //depot/perl@22525 --- diff --git a/pp.c b/pp.c index 8b485fd..866d554 100644 --- a/pp.c +++ b/pp.c @@ -2377,6 +2377,7 @@ PP(pp_complement) register I32 anum; STRLEN len; + (void)SvPV_nomg(sv,len); sv_setsv_nomg(TARG, sv); tmps = (U8*)SvPV_force(TARG, len); anum = len; diff --git a/t/lib/warnings/sv b/t/lib/warnings/sv index 6060fbc..b38200d 100644 --- a/t/lib/warnings/sv +++ b/t/lib/warnings/sv @@ -112,6 +112,26 @@ Use of uninitialized value in bitwise or (|) at - line 4. ######## # sv.c use warnings 'uninitialized' ; +my $Y = 1 ; +my $x = 1 & $a[$Y] ; +no warnings 'uninitialized' ; +my $Y = 1 ; +$x = 1 & $b[$Y] ; +EXPECT +Use of uninitialized value in bitwise and (&) at - line 4. +######## +# sv.c +use warnings 'uninitialized' ; +my $Y = 1 ; +my $x = ~$a[$Y] ; +no warnings 'uninitialized' ; +my $Y = 1 ; +$x = ~$b[$Y] ; +EXPECT +Use of uninitialized value in 1's complement (~) at - line 4. +######## +# sv.c +use warnings 'uninitialized' ; my $x *= 1 ; # d no warnings 'uninitialized' ; my $y *= 1 ; # d