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