xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/lib/warnings/sv (revision 1277:fbc63bc995ee)
10Sstevel@tonic-gate  sv.c
20Sstevel@tonic-gate
30Sstevel@tonic-gate  warn(warn_uninit);
40Sstevel@tonic-gate
50Sstevel@tonic-gate  warn(warn_uninit);
60Sstevel@tonic-gate
70Sstevel@tonic-gate  warn(warn_uninit);
80Sstevel@tonic-gate
90Sstevel@tonic-gate  warn(warn_uninit);
100Sstevel@tonic-gate
110Sstevel@tonic-gate  not_a_number(sv);
120Sstevel@tonic-gate
130Sstevel@tonic-gate  not_a_number(sv);
140Sstevel@tonic-gate
150Sstevel@tonic-gate  warn(warn_uninit);
160Sstevel@tonic-gate
170Sstevel@tonic-gate  not_a_number(sv);
180Sstevel@tonic-gate
190Sstevel@tonic-gate  warn(warn_uninit);
200Sstevel@tonic-gate
210Sstevel@tonic-gate  not_a_number(sv);
220Sstevel@tonic-gate
230Sstevel@tonic-gate  not_a_number(sv);
240Sstevel@tonic-gate
250Sstevel@tonic-gate  warn(warn_uninit);
260Sstevel@tonic-gate
270Sstevel@tonic-gate  warn(warn_uninit);
280Sstevel@tonic-gate
290Sstevel@tonic-gate  Subroutine %s redefined
300Sstevel@tonic-gate
310Sstevel@tonic-gate  Invalid conversion in %s:
320Sstevel@tonic-gate
330Sstevel@tonic-gate  Undefined value assigned to typeglob
340Sstevel@tonic-gate
350Sstevel@tonic-gate  Possible Y2K bug: %d format string following '19'
360Sstevel@tonic-gate
370Sstevel@tonic-gate  Reference is already weak			[Perl_sv_rvweaken] <<TODO
380Sstevel@tonic-gate
390Sstevel@tonic-gate  Mandatory Warnings
400Sstevel@tonic-gate  ------------------
410Sstevel@tonic-gate  Malformed UTF-8 character [sv_pos_b2u] (not tested: difficult to produce
420Sstevel@tonic-gate                                          with perl now)
430Sstevel@tonic-gate
440Sstevel@tonic-gate  Mandatory Warnings TODO
450Sstevel@tonic-gate  ------------------
460Sstevel@tonic-gate    Attempt to free non-arena SV: 0x%lx		[del_sv]
470Sstevel@tonic-gate    Reference miscount in sv_replace()		[sv_replace]
480Sstevel@tonic-gate    Attempt to free unreferenced scalar		[sv_free]
490Sstevel@tonic-gate    Attempt to free temp prematurely: SV 0x%lx	[sv_free]
500Sstevel@tonic-gate    semi-panic: attempt to dup freed string	[newSVsv]
510Sstevel@tonic-gate
520Sstevel@tonic-gate
530Sstevel@tonic-gate__END__
540Sstevel@tonic-gate# sv.c
550Sstevel@tonic-gateuse integer ;
560Sstevel@tonic-gateuse warnings 'uninitialized' ;
570Sstevel@tonic-gate$x = 1 + $a[0] ; # a
580Sstevel@tonic-gateno warnings 'uninitialized' ;
590Sstevel@tonic-gate$x = 1 + $b[0] ; # a
600Sstevel@tonic-gateEXPECT
610Sstevel@tonic-gateUse of uninitialized value in integer addition (+) at - line 4.
620Sstevel@tonic-gate########
630Sstevel@tonic-gate# sv.c (sv_2iv)
640Sstevel@tonic-gatepackage fred ;
650Sstevel@tonic-gatesub TIESCALAR { my $x ; bless \$x}
660Sstevel@tonic-gatesub FETCH { return undef }
670Sstevel@tonic-gatesub STORE { return 1 }
680Sstevel@tonic-gatepackage main ;
690Sstevel@tonic-gatetie $A, 'fred' ;
700Sstevel@tonic-gateuse integer ;
710Sstevel@tonic-gateuse warnings 'uninitialized' ;
720Sstevel@tonic-gate$A *= 2 ;
730Sstevel@tonic-gateno warnings 'uninitialized' ;
740Sstevel@tonic-gate$A *= 2 ;
750Sstevel@tonic-gateEXPECT
760Sstevel@tonic-gateUse of uninitialized value in integer multiplication (*) at - line 10.
770Sstevel@tonic-gate########
780Sstevel@tonic-gate# sv.c
790Sstevel@tonic-gateuse integer ;
800Sstevel@tonic-gateuse warnings 'uninitialized' ;
810Sstevel@tonic-gatemy $x *= 2 ; #b
820Sstevel@tonic-gateno warnings 'uninitialized' ;
830Sstevel@tonic-gatemy $y *= 2 ; #b
840Sstevel@tonic-gateEXPECT
850Sstevel@tonic-gateUse of uninitialized value in integer multiplication (*) at - line 4.
860Sstevel@tonic-gate########
870Sstevel@tonic-gate# sv.c (sv_2uv)
880Sstevel@tonic-gatepackage fred ;
890Sstevel@tonic-gatesub TIESCALAR { my $x ; bless \$x}
900Sstevel@tonic-gatesub FETCH { return undef }
910Sstevel@tonic-gatesub STORE { return 1 }
920Sstevel@tonic-gatepackage main ;
930Sstevel@tonic-gatetie $A, 'fred' ;
940Sstevel@tonic-gateuse warnings 'uninitialized' ;
950Sstevel@tonic-gate$B = 0 ;
960Sstevel@tonic-gate$B |= $A ;
970Sstevel@tonic-gateno warnings 'uninitialized' ;
980Sstevel@tonic-gate$B = 0 ;
990Sstevel@tonic-gate$B |= $A ;
1000Sstevel@tonic-gateEXPECT
1010Sstevel@tonic-gateUse of uninitialized value in bitwise or (|) at - line 10.
1020Sstevel@tonic-gate########
1030Sstevel@tonic-gate# sv.c
1040Sstevel@tonic-gateuse warnings 'uninitialized' ;
1050Sstevel@tonic-gatemy $Y = 1 ;
1060Sstevel@tonic-gatemy $x = 1 | $a[$Y] ;
1070Sstevel@tonic-gateno warnings 'uninitialized' ;
1080Sstevel@tonic-gatemy $Y = 1 ;
1090Sstevel@tonic-gate$x = 1 | $b[$Y] ;
1100Sstevel@tonic-gateEXPECT
1110Sstevel@tonic-gateUse of uninitialized value in bitwise or (|) at - line 4.
1120Sstevel@tonic-gate########
1130Sstevel@tonic-gate# sv.c
1140Sstevel@tonic-gateuse warnings 'uninitialized' ;
1150Sstevel@tonic-gatemy $Y = 1 ;
1160Sstevel@tonic-gatemy $x = 1 & $a[$Y] ;
1170Sstevel@tonic-gateno warnings 'uninitialized' ;
1180Sstevel@tonic-gatemy $Y = 1 ;
1190Sstevel@tonic-gate$x = 1 & $b[$Y] ;
1200Sstevel@tonic-gateEXPECT
1210Sstevel@tonic-gateUse of uninitialized value in bitwise and (&) at - line 4.
1220Sstevel@tonic-gate########
1230Sstevel@tonic-gate# sv.c
1240Sstevel@tonic-gateuse warnings 'uninitialized' ;
1250Sstevel@tonic-gatemy $Y = 1 ;
1260Sstevel@tonic-gatemy $x = ~$a[$Y] ;
1270Sstevel@tonic-gateno warnings 'uninitialized' ;
1280Sstevel@tonic-gatemy $Y = 1 ;
1290Sstevel@tonic-gate$x = ~$b[$Y] ;
1300Sstevel@tonic-gateEXPECT
1310Sstevel@tonic-gateUse of uninitialized value in 1's complement (~) at - line 4.
1320Sstevel@tonic-gate########
1330Sstevel@tonic-gate# sv.c
1340Sstevel@tonic-gateuse warnings 'uninitialized' ;
1350Sstevel@tonic-gatemy $x *= 1 ; # d
1360Sstevel@tonic-gateno warnings 'uninitialized' ;
1370Sstevel@tonic-gatemy $y *= 1 ; # d
1380Sstevel@tonic-gateEXPECT
1390Sstevel@tonic-gateUse of uninitialized value in multiplication (*) at - line 3.
1400Sstevel@tonic-gate########
1410Sstevel@tonic-gate# sv.c
1420Sstevel@tonic-gateuse warnings 'uninitialized' ;
1430Sstevel@tonic-gate$x = 1 + $a[0] ; # e
1440Sstevel@tonic-gateno warnings 'uninitialized' ;
1450Sstevel@tonic-gate$x = 1 + $b[0] ; # e
1460Sstevel@tonic-gateEXPECT
1470Sstevel@tonic-gateUse of uninitialized value in addition (+) at - line 3.
1480Sstevel@tonic-gate########
1490Sstevel@tonic-gate# sv.c (sv_2nv)
1500Sstevel@tonic-gatepackage fred ;
1510Sstevel@tonic-gatesub TIESCALAR { my $x ; bless \$x}
1520Sstevel@tonic-gatesub FETCH { return undef }
1530Sstevel@tonic-gatesub STORE { return 1 }
1540Sstevel@tonic-gatepackage main ;
1550Sstevel@tonic-gatetie $A, 'fred' ;
1560Sstevel@tonic-gateuse warnings 'uninitialized' ;
1570Sstevel@tonic-gate$A *= 2 ;
1580Sstevel@tonic-gateno warnings 'uninitialized' ;
1590Sstevel@tonic-gate$A *= 2 ;
1600Sstevel@tonic-gateEXPECT
1610Sstevel@tonic-gateUse of uninitialized value in multiplication (*) at - line 9.
1620Sstevel@tonic-gate########
1630Sstevel@tonic-gate# sv.c
1640Sstevel@tonic-gateuse warnings 'uninitialized' ;
1650Sstevel@tonic-gate$x = $y + 1 ; # f
1660Sstevel@tonic-gateno warnings 'uninitialized' ;
1670Sstevel@tonic-gate$x = $z + 1 ; # f
1680Sstevel@tonic-gateEXPECT
1690Sstevel@tonic-gateUse of uninitialized value in addition (+) at - line 3.
1700Sstevel@tonic-gate########
1710Sstevel@tonic-gate# sv.c
1720Sstevel@tonic-gateuse warnings 'uninitialized' ;
1730Sstevel@tonic-gate$x = chop undef ; # g
1740Sstevel@tonic-gateno warnings 'uninitialized' ;
1750Sstevel@tonic-gate$x = chop undef ; # g
1760Sstevel@tonic-gateEXPECT
1770Sstevel@tonic-gateModification of a read-only value attempted at - line 3.
1780Sstevel@tonic-gate########
1790Sstevel@tonic-gate# sv.c
1800Sstevel@tonic-gateuse warnings 'uninitialized' ;
1810Sstevel@tonic-gate$x = chop $y ; # h
1820Sstevel@tonic-gateno warnings 'uninitialized' ;
1830Sstevel@tonic-gate$x = chop $z ; # h
1840Sstevel@tonic-gateEXPECT
1850Sstevel@tonic-gateUse of uninitialized value in scalar chop at - line 3.
1860Sstevel@tonic-gate########
1870Sstevel@tonic-gate# sv.c (sv_2pv)
1880Sstevel@tonic-gatepackage fred ;
1890Sstevel@tonic-gatesub TIESCALAR { my $x ; bless \$x}
1900Sstevel@tonic-gatesub FETCH { return undef }
1910Sstevel@tonic-gatesub STORE { return 1 }
1920Sstevel@tonic-gatepackage main ;
1930Sstevel@tonic-gatetie $A, 'fred' ;
1940Sstevel@tonic-gateuse warnings 'uninitialized' ;
1950Sstevel@tonic-gate$B = "" ;
1960Sstevel@tonic-gate$B .= $A ;
1970Sstevel@tonic-gateno warnings 'uninitialized' ;
1980Sstevel@tonic-gate$C = "" ;
1990Sstevel@tonic-gate$C .= $A ;
2000Sstevel@tonic-gateEXPECT
2010Sstevel@tonic-gateUse of uninitialized value in concatenation (.) or string at - line 10.
2020Sstevel@tonic-gate########
2030Sstevel@tonic-gate# perlbug 20011116.125
2040Sstevel@tonic-gateuse warnings 'uninitialized';
2050Sstevel@tonic-gate$a = undef;
2060Sstevel@tonic-gate$foo = join '', $a, "\n";
2070Sstevel@tonic-gate$foo = "$a\n";
2080Sstevel@tonic-gate$foo = "a:$a\n";
2090Sstevel@tonic-gateEXPECT
2100Sstevel@tonic-gateUse of uninitialized value in join or string at - line 4.
2110Sstevel@tonic-gateUse of uninitialized value in concatenation (.) or string at - line 5.
2120Sstevel@tonic-gateUse of uninitialized value in concatenation (.) or string at - line 6.
2130Sstevel@tonic-gate########
2140Sstevel@tonic-gate# sv.c
2150Sstevel@tonic-gateuse warnings 'numeric' ;
2160Sstevel@tonic-gatesub TIESCALAR{bless[]} ;
2170Sstevel@tonic-gatesub FETCH {"def"} ;
2180Sstevel@tonic-gatetie $a,"main" ;
2190Sstevel@tonic-gatemy $b = 1 + $a;
2200Sstevel@tonic-gateno warnings 'numeric' ;
2210Sstevel@tonic-gatemy $c = 1 + $a;
2220Sstevel@tonic-gateEXPECT
2230Sstevel@tonic-gateArgument "def" isn't numeric in addition (+) at - line 6.
2240Sstevel@tonic-gate########
2250Sstevel@tonic-gate# sv.c
2260Sstevel@tonic-gateuse warnings 'numeric' ;
2270Sstevel@tonic-gatemy $x = 1 + "def" ;
2280Sstevel@tonic-gateno warnings 'numeric' ;
2290Sstevel@tonic-gatemy $z = 1 + "def" ;
2300Sstevel@tonic-gateEXPECT
2310Sstevel@tonic-gateArgument "def" isn't numeric in addition (+) at - line 3.
2320Sstevel@tonic-gate########
2330Sstevel@tonic-gate# sv.c
2340Sstevel@tonic-gateuse warnings 'numeric' ;
2350Sstevel@tonic-gatemy $a = "def" ;
2360Sstevel@tonic-gatemy $x = 1 + $a ;
2370Sstevel@tonic-gateno warnings 'numeric' ;
2380Sstevel@tonic-gatemy $y = 1 + $a ;
2390Sstevel@tonic-gateEXPECT
2400Sstevel@tonic-gateArgument "def" isn't numeric in addition (+) at - line 4.
2410Sstevel@tonic-gate########
2420Sstevel@tonic-gate# sv.c
2430Sstevel@tonic-gateuse warnings 'numeric' ; use integer ;
2440Sstevel@tonic-gatemy $a = "def" ;
2450Sstevel@tonic-gatemy $x = 1 + $a ;
2460Sstevel@tonic-gateno warnings 'numeric' ;
2470Sstevel@tonic-gatemy $z = 1 + $a ;
2480Sstevel@tonic-gateEXPECT
2490Sstevel@tonic-gateArgument "def" isn't numeric in integer addition (+) at - line 4.
2500Sstevel@tonic-gate########
2510Sstevel@tonic-gate# sv.c
2520Sstevel@tonic-gateuse warnings 'numeric' ;
2530Sstevel@tonic-gatemy $x = 1 & "def" ;
2540Sstevel@tonic-gateno warnings 'numeric' ;
2550Sstevel@tonic-gatemy $z = 1 & "def" ;
2560Sstevel@tonic-gateEXPECT
2570Sstevel@tonic-gateArgument "def" isn't numeric in bitwise and (&) at - line 3.
2580Sstevel@tonic-gate########
2590Sstevel@tonic-gate# sv.c
2600Sstevel@tonic-gateuse warnings 'numeric' ;
2610Sstevel@tonic-gatemy $x = pack i => "def" ;
2620Sstevel@tonic-gateno warnings 'numeric' ;
2630Sstevel@tonic-gatemy $z = pack i => "def" ;
2640Sstevel@tonic-gateEXPECT
2650Sstevel@tonic-gateArgument "def" isn't numeric in pack at - line 3.
2660Sstevel@tonic-gate########
2670Sstevel@tonic-gate# sv.c
2680Sstevel@tonic-gateuse warnings 'numeric' ;
2690Sstevel@tonic-gatemy $a = "d\0f" ;
2700Sstevel@tonic-gatemy $x = 1 + $a ;
2710Sstevel@tonic-gateno warnings 'numeric' ;
2720Sstevel@tonic-gatemy $z = 1 + $a ;
2730Sstevel@tonic-gateEXPECT
2740Sstevel@tonic-gateArgument "d\0f" isn't numeric in addition (+) at - line 4.
2750Sstevel@tonic-gate########
2760Sstevel@tonic-gate# sv.c
2770Sstevel@tonic-gateuse warnings 'redefine' ;
2780Sstevel@tonic-gatesub fred {}
2790Sstevel@tonic-gatesub joe {}
2800Sstevel@tonic-gate*fred = \&joe ;
2810Sstevel@tonic-gateno warnings 'redefine' ;
2820Sstevel@tonic-gatesub jim {}
2830Sstevel@tonic-gate*jim = \&joe ;
2840Sstevel@tonic-gateEXPECT
2850Sstevel@tonic-gateSubroutine main::fred redefined at - line 5.
2860Sstevel@tonic-gate########
2870Sstevel@tonic-gate# sv.c
2880Sstevel@tonic-gateuse warnings 'printf' ;
2890Sstevel@tonic-gateopen F, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
2900Sstevel@tonic-gateprintf F "%z\n" ;
2910Sstevel@tonic-gatemy $a = sprintf "%z" ;
2920Sstevel@tonic-gateprintf F "%" ;
2930Sstevel@tonic-gate$a = sprintf "%" ;
2940Sstevel@tonic-gateprintf F "%\x02" ;
2950Sstevel@tonic-gate$a = sprintf "%\x02" ;
2960Sstevel@tonic-gateno warnings 'printf' ;
2970Sstevel@tonic-gateprintf F "%z\n" ;
2980Sstevel@tonic-gate$a = sprintf "%z" ;
2990Sstevel@tonic-gateprintf F "%" ;
3000Sstevel@tonic-gate$a = sprintf "%" ;
3010Sstevel@tonic-gateprintf F "%\x02" ;
3020Sstevel@tonic-gate$a = sprintf "%\x02" ;
3030Sstevel@tonic-gateEXPECT
304*1277SalanburInvalid conversion in printf: "%z" at - line 4.
3050Sstevel@tonic-gateInvalid conversion in sprintf: "%z" at - line 5.
306*1277SalanburInvalid conversion in printf: end of string at - line 6.
3070Sstevel@tonic-gateInvalid conversion in sprintf: end of string at - line 7.
308*1277SalanburInvalid conversion in printf: "%\002" at - line 8.
3090Sstevel@tonic-gateInvalid conversion in sprintf: "%\002" at - line 9.
3100Sstevel@tonic-gate########
3110Sstevel@tonic-gate# sv.c
3120Sstevel@tonic-gateuse warnings 'misc' ;
3130Sstevel@tonic-gate*a = undef ;
3140Sstevel@tonic-gateno warnings 'misc' ;
3150Sstevel@tonic-gate*b = undef ;
3160Sstevel@tonic-gateEXPECT
3170Sstevel@tonic-gateUndefined value assigned to typeglob at - line 3.
3180Sstevel@tonic-gate########
3190Sstevel@tonic-gate# sv.c
3200Sstevel@tonic-gateuse warnings 'y2k';
3210Sstevel@tonic-gateuse Config;
3220Sstevel@tonic-gateBEGIN {
3230Sstevel@tonic-gate    unless ($Config{ccflags} =~ /Y2KWARN/) {
3240Sstevel@tonic-gate	print "SKIPPED\n# perl not built with -DPERL_Y2KWARN";
3250Sstevel@tonic-gate	exit 0;
3260Sstevel@tonic-gate    }
3270Sstevel@tonic-gate    $|=1;
3280Sstevel@tonic-gate}
3290Sstevel@tonic-gatemy $x;
3300Sstevel@tonic-gatemy $yy = 78;
3310Sstevel@tonic-gate$x     = printf  "19%02d\n", $yy;
3320Sstevel@tonic-gate$x     = sprintf "#19%02d\n", $yy;
3330Sstevel@tonic-gate$x     = printf  " 19%02d\n", 78;
3340Sstevel@tonic-gate$x     = sprintf "19%02d\n", 78;
3350Sstevel@tonic-gate$x     = printf  "319%02d\n", $yy;
3360Sstevel@tonic-gate$x     = sprintf "319%02d\n", $yy;
3370Sstevel@tonic-gateno warnings 'y2k';
3380Sstevel@tonic-gate$x     = printf  "19%02d\n", $yy;
3390Sstevel@tonic-gate$x     = sprintf "19%02d\n", $yy;
3400Sstevel@tonic-gate$x     = printf  "19%02d\n", 78;
3410Sstevel@tonic-gate$x     = sprintf "19%02d\n", 78;
3420Sstevel@tonic-gateEXPECT
3430Sstevel@tonic-gatePossible Y2K bug: %d format string following '19' at - line 16.
3440Sstevel@tonic-gatePossible Y2K bug: %d format string following '19' at - line 13.
3450Sstevel@tonic-gate1978
3460Sstevel@tonic-gatePossible Y2K bug: %d format string following '19' at - line 14.
3470Sstevel@tonic-gatePossible Y2K bug: %d format string following '19' at - line 15.
3480Sstevel@tonic-gate 1978
3490Sstevel@tonic-gate31978
3500Sstevel@tonic-gate1978
3510Sstevel@tonic-gate1978
3520Sstevel@tonic-gate########
3530Sstevel@tonic-gate# sv.c
3540Sstevel@tonic-gateuse warnings 'numeric' ;
3550Sstevel@tonic-gate$a = "\x{100}\x{200}" * 42;
3560Sstevel@tonic-gateno warnings 'numeric' ;
3570Sstevel@tonic-gate$a = "\x{100}\x{200}" * 42;
3580Sstevel@tonic-gateEXPECT
3590Sstevel@tonic-gateArgument "\x{100}\x{200}" isn't numeric in multiplication (*) at - line 3.
3600Sstevel@tonic-gate########
3610Sstevel@tonic-gate# sv.c
3620Sstevel@tonic-gateuse warnings 'numeric' ;
3630Sstevel@tonic-gate$a = "\x{100}\x{200}"; $a = -$a;
3640Sstevel@tonic-gateno warnings 'numeric' ;
3650Sstevel@tonic-gate$a = "\x{100}\x{200}"; $a = -$a;
3660Sstevel@tonic-gateEXPECT
3670Sstevel@tonic-gateArgument "\x{100}\x{200}" isn't numeric in negation (-) at - line 3.
3680Sstevel@tonic-gate########
3690Sstevel@tonic-gate# sv.c
3700Sstevel@tonic-gateopen F, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
3710Sstevel@tonic-gateuse warnings 'printf';
3720Sstevel@tonic-gate$a = "a\nb";
3730Sstevel@tonic-gate$s = sprintf "%4s", $a;
3740Sstevel@tonic-gateprintf F "%4s", $a;
3750Sstevel@tonic-gate$s = sprintf "%-4s", $a;
3760Sstevel@tonic-gateprintf F "%-4s", $a;
3770Sstevel@tonic-gate$s = sprintf "%*s", -4, $a;
3780Sstevel@tonic-gateno warnings 'printf';
3790Sstevel@tonic-gate$s = sprintf "%4s", $a;
3800Sstevel@tonic-gateprintf F "%4s", $a;
3810Sstevel@tonic-gate$s = sprintf "%-4s", $a;
3820Sstevel@tonic-gateprintf F "%-4s", $a;
3830Sstevel@tonic-gateEXPECT
3840Sstevel@tonic-gateNewline in left-justified string for sprintf at - line 7.
3850Sstevel@tonic-gateNewline in left-justified string for printf at - line 8.
3860Sstevel@tonic-gateNewline in left-justified string for sprintf at - line 9.
387