This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make ~$x give warning is $x isn't initialised.
authorDave Mitchell <davem@fdisolutions.com>
Thu, 18 Mar 2004 14:13:16 +0000 (14:13 +0000)
committerDave Mitchell <davem@fdisolutions.com>
Thu, 18 Mar 2004 14:13:16 +0000 (14:13 +0000)
Also add test for uninitialised warning in & op.

p4raw-id: //depot/perl@22525

pp.c
t/lib/warnings/sv

diff --git a/pp.c b/pp.c
index 8b485fd..866d554 100644 (file)
--- 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;
index 6060fbc..b38200d 100644 (file)
@@ -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