Integrate mainline
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / sv
CommitLineData
0453d815 1 sv.c
599cee73 2
3 warn(warn_uninit);
4
5 warn(warn_uninit);
6
7 warn(warn_uninit);
8
9 warn(warn_uninit);
10
11 not_a_number(sv);
12
13 not_a_number(sv);
14
15 warn(warn_uninit);
16
17 not_a_number(sv);
18
19 warn(warn_uninit);
20
21 not_a_number(sv);
22
23 not_a_number(sv);
24
25 warn(warn_uninit);
26
27 warn(warn_uninit);
28
29 Subroutine %s redefined
30
31 Invalid conversion in %s:
32
33 Undefined value assigned to typeglob
34
6bc102ca 35 Possible Y2K bug: %d format string following '19'
36
767a6a26 37 Reference is already weak [Perl_sv_rvweaken] <<TODO
38
0453d815 39 Mandatory Warnings
40 ------------------
7e2040f0 41 Malformed UTF-8 character [sv_pos_b2u] (not tested: difficult to produce
42 with perl now)
0453d815 43
44 Mandatory Warnings TODO
45 ------------------
46 Attempt to free non-arena SV: 0x%lx [del_sv]
47 Reference miscount in sv_replace() [sv_replace]
48 Attempt to free unreferenced scalar [sv_free]
49 Attempt to free temp prematurely: SV 0x%lx [sv_free]
50 semi-panic: attempt to dup freed string [newSVsv]
51
599cee73 52
53__END__
54# sv.c
55use integer ;
4438c4b7 56use warnings 'uninitialized' ;
599cee73 57$x = 1 + $a[0] ; # a
4438c4b7 58no warnings 'uninitialized' ;
0453d815 59$x = 1 + $b[0] ; # a
599cee73 60EXPECT
b89fed5f 61Use of uninitialized value in integer addition (+) at - line 4.
599cee73 62########
63# sv.c (sv_2iv)
64package fred ;
65sub TIESCALAR { my $x ; bless \$x}
66sub FETCH { return undef }
67sub STORE { return 1 }
68package main ;
69tie $A, 'fred' ;
70use integer ;
4438c4b7 71use warnings 'uninitialized' ;
599cee73 72$A *= 2 ;
4438c4b7 73no warnings 'uninitialized' ;
0453d815 74$A *= 2 ;
599cee73 75EXPECT
b89fed5f 76Use of uninitialized value in integer multiplication (*) at - line 10.
599cee73 77########
78# sv.c
79use integer ;
4438c4b7 80use warnings 'uninitialized' ;
599cee73 81my $x *= 2 ; #b
4438c4b7 82no warnings 'uninitialized' ;
0453d815 83my $y *= 2 ; #b
599cee73 84EXPECT
b89fed5f 85Use of uninitialized value in integer multiplication (*) at - line 4.
599cee73 86########
87# sv.c (sv_2uv)
88package fred ;
89sub TIESCALAR { my $x ; bless \$x}
90sub FETCH { return undef }
91sub STORE { return 1 }
92package main ;
93tie $A, 'fred' ;
4438c4b7 94use warnings 'uninitialized' ;
599cee73 95$B = 0 ;
96$B |= $A ;
4438c4b7 97no warnings 'uninitialized' ;
0453d815 98$B = 0 ;
99$B |= $A ;
599cee73 100EXPECT
b89fed5f 101Use of uninitialized value in bitwise or (|) at - line 10.
599cee73 102########
103# sv.c
4438c4b7 104use warnings 'uninitialized' ;
599cee73 105my $Y = 1 ;
0453d815 106my $x = 1 | $a[$Y] ;
4438c4b7 107no warnings 'uninitialized' ;
0453d815 108my $Y = 1 ;
109$x = 1 | $b[$Y] ;
599cee73 110EXPECT
b89fed5f 111Use of uninitialized value in bitwise or (|) at - line 4.
599cee73 112########
113# sv.c
4438c4b7 114use warnings 'uninitialized' ;
599cee73 115my $x *= 1 ; # d
4438c4b7 116no warnings 'uninitialized' ;
0453d815 117my $y *= 1 ; # d
599cee73 118EXPECT
b89fed5f 119Use of uninitialized value in multiplication (*) at - line 3.
599cee73 120########
121# sv.c
4438c4b7 122use warnings 'uninitialized' ;
599cee73 123$x = 1 + $a[0] ; # e
4438c4b7 124no warnings 'uninitialized' ;
0453d815 125$x = 1 + $b[0] ; # e
599cee73 126EXPECT
b89fed5f 127Use of uninitialized value in addition (+) at - line 3.
599cee73 128########
129# sv.c (sv_2nv)
130package fred ;
131sub TIESCALAR { my $x ; bless \$x}
132sub FETCH { return undef }
133sub STORE { return 1 }
134package main ;
135tie $A, 'fred' ;
4438c4b7 136use warnings 'uninitialized' ;
599cee73 137$A *= 2 ;
4438c4b7 138no warnings 'uninitialized' ;
0453d815 139$A *= 2 ;
599cee73 140EXPECT
b89fed5f 141Use of uninitialized value in multiplication (*) at - line 9.
599cee73 142########
143# sv.c
4438c4b7 144use warnings 'uninitialized' ;
599cee73 145$x = $y + 1 ; # f
4438c4b7 146no warnings 'uninitialized' ;
0453d815 147$x = $z + 1 ; # f
599cee73 148EXPECT
b89fed5f 149Use of uninitialized value in addition (+) at - line 3.
599cee73 150########
151# sv.c
4438c4b7 152use warnings 'uninitialized' ;
599cee73 153$x = chop undef ; # g
4438c4b7 154no warnings 'uninitialized' ;
0453d815 155$x = chop undef ; # g
599cee73 156EXPECT
b0c98cec 157Modification of a read-only value attempted at - line 3.
599cee73 158########
159# sv.c
4438c4b7 160use warnings 'uninitialized' ;
599cee73 161$x = chop $y ; # h
4438c4b7 162no warnings 'uninitialized' ;
0453d815 163$x = chop $z ; # h
599cee73 164EXPECT
b89fed5f 165Use of uninitialized value in scalar chop at - line 3.
599cee73 166########
167# sv.c (sv_2pv)
168package fred ;
169sub TIESCALAR { my $x ; bless \$x}
170sub FETCH { return undef }
171sub STORE { return 1 }
172package main ;
173tie $A, 'fred' ;
4438c4b7 174use warnings 'uninitialized' ;
599cee73 175$B = "" ;
176$B .= $A ;
4438c4b7 177no warnings 'uninitialized' ;
0453d815 178$C = "" ;
179$C .= $A ;
599cee73 180EXPECT
297b36dc 181Use of uninitialized value in concatenation (.) or string at - line 10.
599cee73 182########
531d2254 183# perlbug 20011116.125
184use warnings 'uninitialized';
185$a = undef;
186$foo = join '', $a, "\n";
187$foo = "$a\n";
188$foo = "a:$a\n";
189EXPECT
190Use of uninitialized value in join or string at - line 4.
191Use of uninitialized value in concatenation (.) or string at - line 5.
192Use of uninitialized value in concatenation (.) or string at - line 6.
193########
599cee73 194# sv.c
4438c4b7 195use warnings 'numeric' ;
599cee73 196sub TIESCALAR{bless[]} ;
197sub FETCH {"def"} ;
198tie $a,"main" ;
0453d815 199my $b = 1 + $a;
4438c4b7 200no warnings 'numeric' ;
0453d815 201my $c = 1 + $a;
599cee73 202EXPECT
42d38218 203Argument "def" isn't numeric in addition (+) at - line 6.
599cee73 204########
205# sv.c
4438c4b7 206use warnings 'numeric' ;
599cee73 207my $x = 1 + "def" ;
4438c4b7 208no warnings 'numeric' ;
0453d815 209my $z = 1 + "def" ;
599cee73 210EXPECT
42d38218 211Argument "def" isn't numeric in addition (+) at - line 3.
599cee73 212########
213# sv.c
4438c4b7 214use warnings 'numeric' ;
599cee73 215my $a = "def" ;
216my $x = 1 + $a ;
4438c4b7 217no warnings 'numeric' ;
0453d815 218my $y = 1 + $a ;
599cee73 219EXPECT
42d38218 220Argument "def" isn't numeric in addition (+) at - line 4.
599cee73 221########
222# sv.c
4438c4b7 223use warnings 'numeric' ; use integer ;
599cee73 224my $a = "def" ;
225my $x = 1 + $a ;
4438c4b7 226no warnings 'numeric' ;
0453d815 227my $z = 1 + $a ;
599cee73 228EXPECT
42d38218 229Argument "def" isn't numeric in integer addition (+) at - line 4.
599cee73 230########
231# sv.c
4438c4b7 232use warnings 'numeric' ;
599cee73 233my $x = 1 & "def" ;
4438c4b7 234no warnings 'numeric' ;
0453d815 235my $z = 1 & "def" ;
599cee73 236EXPECT
42d38218 237Argument "def" isn't numeric in bitwise and (&) at - line 3.
599cee73 238########
239# sv.c
59bb5845 240use warnings 'numeric' ;
241my $x = pack i => "def" ;
242no warnings 'numeric' ;
243my $z = pack i => "def" ;
244EXPECT
245Argument "def" isn't numeric in pack at - line 3.
246########
247# sv.c
248use warnings 'numeric' ;
249my $a = "d\0f" ;
250my $x = 1 + $a ;
251no warnings 'numeric' ;
252my $z = 1 + $a ;
253EXPECT
254Argument "d\0f" isn't numeric in addition (+) at - line 4.
255########
256# sv.c
4438c4b7 257use warnings 'redefine' ;
599cee73 258sub fred {}
259sub joe {}
260*fred = \&joe ;
4438c4b7 261no warnings 'redefine' ;
0453d815 262sub jim {}
263*jim = \&joe ;
599cee73 264EXPECT
80a5d8e7 265Subroutine main::fred redefined at - line 5.
599cee73 266########
267# sv.c
4438c4b7 268use warnings 'printf' ;
3eeba6fb 269open F, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
cf2093f6 270printf F "%z\n" ;
271my $a = sprintf "%z" ;
599cee73 272printf F "%" ;
273$a = sprintf "%" ;
274printf F "%\x02" ;
275$a = sprintf "%\x02" ;
4438c4b7 276no warnings 'printf' ;
cf2093f6 277printf F "%z\n" ;
278$a = sprintf "%z" ;
0453d815 279printf F "%" ;
280$a = sprintf "%" ;
281printf F "%\x02" ;
282$a = sprintf "%\x02" ;
599cee73 283EXPECT
cf2093f6 284Invalid conversion in sprintf: "%z" at - line 5.
599cee73 285Invalid conversion in sprintf: end of string at - line 7.
286Invalid conversion in sprintf: "%\002" at - line 9.
cf2093f6 287Invalid conversion in printf: "%z" at - line 4.
599cee73 288Invalid conversion in printf: end of string at - line 6.
289Invalid conversion in printf: "%\002" at - line 8.
290########
291# sv.c
e476b1b5 292use warnings 'misc' ;
599cee73 293*a = undef ;
e476b1b5 294no warnings 'misc' ;
0453d815 295*b = undef ;
599cee73 296EXPECT
297Undefined value assigned to typeglob at - line 3.
0453d815 298########
299# sv.c
e476b1b5 300use warnings 'y2k';
6bc102ca 301use Config;
302BEGIN {
303 unless ($Config{ccflags} =~ /Y2KWARN/) {
304 print "SKIPPED\n# perl not built with -DPERL_Y2KWARN";
305 exit 0;
306 }
307 $|=1;
308}
309my $x;
310my $yy = 78;
311$x = printf "19%02d\n", $yy;
312$x = sprintf "#19%02d\n", $yy;
313$x = printf " 19%02d\n", 78;
314$x = sprintf "19%02d\n", 78;
315$x = printf "319%02d\n", $yy;
316$x = sprintf "319%02d\n", $yy;
e476b1b5 317no warnings 'y2k';
6bc102ca 318$x = printf "19%02d\n", $yy;
319$x = sprintf "19%02d\n", $yy;
320$x = printf "19%02d\n", 78;
321$x = sprintf "19%02d\n", 78;
322EXPECT
323Possible Y2K bug: %d format string following '19' at - line 16.
324Possible Y2K bug: %d format string following '19' at - line 13.
3251978
326Possible Y2K bug: %d format string following '19' at - line 14.
327Possible Y2K bug: %d format string following '19' at - line 15.
328 1978
32931978
3301978
3311978
94463019 332########
333# sv.c
334use warnings 'numeric' ;
335$a = "\x{100}\x{200}" * 42;
336no warnings 'numeric' ;
337$a = "\x{100}\x{200}" * 42;
338EXPECT
339Argument "\x{100}\x{200}" isn't numeric in multiplication (*) at - line 3.
8eb28a70 340########
341# sv.c
342use warnings 'numeric' ;
343$a = "\x{100}\x{200}"; $a = -$a;
344no warnings 'numeric' ;
345$a = "\x{100}\x{200}"; $a = -$a;
346EXPECT
347Argument "\x{100}\x{200}" isn't numeric in negation (-) at - line 3.