Fix UV_SIZEOF to UVSIZE; change the overflow tests
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / 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 ------------------
39 Malformed UTF-8 character [sv_pos_b2u]
40 my $a = rindex "a\xff bc ", "bc" ;
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
59Use of uninitialized value at - line 4.
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
74Use of uninitialized value at - line 10.
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
83Use of uninitialized value at - line 4.
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
99Use of uninitialized value at - line 10.
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
109Use of uninitialized value at - line 4.
110########
111# sv.c
4438c4b7 112use warnings 'uninitialized' ;
599cee73 113my $x *= 1 ; # d
4438c4b7 114no warnings 'uninitialized' ;
0453d815 115my $y *= 1 ; # d
599cee73 116EXPECT
117Use of uninitialized value at - line 3.
118########
119# sv.c
4438c4b7 120use warnings 'uninitialized' ;
599cee73 121$x = 1 + $a[0] ; # e
4438c4b7 122no warnings 'uninitialized' ;
0453d815 123$x = 1 + $b[0] ; # e
599cee73 124EXPECT
125Use of uninitialized value at - line 3.
126########
127# sv.c (sv_2nv)
128package fred ;
129sub TIESCALAR { my $x ; bless \$x}
130sub FETCH { return undef }
131sub STORE { return 1 }
132package main ;
133tie $A, 'fred' ;
4438c4b7 134use warnings 'uninitialized' ;
599cee73 135$A *= 2 ;
4438c4b7 136no warnings 'uninitialized' ;
0453d815 137$A *= 2 ;
599cee73 138EXPECT
139Use of uninitialized value at - line 9.
140########
141# sv.c
4438c4b7 142use warnings 'uninitialized' ;
599cee73 143$x = $y + 1 ; # f
4438c4b7 144no warnings 'uninitialized' ;
0453d815 145$x = $z + 1 ; # f
599cee73 146EXPECT
147Use of uninitialized value at - line 3.
148########
149# sv.c
4438c4b7 150use warnings 'uninitialized' ;
599cee73 151$x = chop undef ; # g
4438c4b7 152no warnings 'uninitialized' ;
0453d815 153$x = chop undef ; # g
599cee73 154EXPECT
b0c98cec 155Modification of a read-only value attempted at - line 3.
599cee73 156########
157# sv.c
4438c4b7 158use warnings 'uninitialized' ;
599cee73 159$x = chop $y ; # h
4438c4b7 160no warnings 'uninitialized' ;
0453d815 161$x = chop $z ; # h
599cee73 162EXPECT
163Use of uninitialized value at - line 3.
164########
165# sv.c (sv_2pv)
166package fred ;
167sub TIESCALAR { my $x ; bless \$x}
168sub FETCH { return undef }
169sub STORE { return 1 }
170package main ;
171tie $A, 'fred' ;
4438c4b7 172use warnings 'uninitialized' ;
599cee73 173$B = "" ;
174$B .= $A ;
4438c4b7 175no warnings 'uninitialized' ;
0453d815 176$C = "" ;
177$C .= $A ;
599cee73 178EXPECT
179Use of uninitialized value at - line 10.
180########
181# sv.c
4438c4b7 182use warnings 'numeric' ;
599cee73 183sub TIESCALAR{bless[]} ;
184sub FETCH {"def"} ;
185tie $a,"main" ;
0453d815 186my $b = 1 + $a;
4438c4b7 187no warnings 'numeric' ;
0453d815 188my $c = 1 + $a;
599cee73 189EXPECT
190Argument "def" isn't numeric in add at - line 6.
191########
192# sv.c
4438c4b7 193use warnings 'numeric' ;
599cee73 194my $x = 1 + "def" ;
4438c4b7 195no warnings 'numeric' ;
0453d815 196my $z = 1 + "def" ;
599cee73 197EXPECT
198Argument "def" isn't numeric in add at - line 3.
199########
200# sv.c
4438c4b7 201use warnings 'numeric' ;
599cee73 202my $a = "def" ;
203my $x = 1 + $a ;
4438c4b7 204no warnings 'numeric' ;
0453d815 205my $y = 1 + $a ;
599cee73 206EXPECT
207Argument "def" isn't numeric in add at - line 4.
208########
209# sv.c
4438c4b7 210use warnings 'numeric' ; use integer ;
599cee73 211my $a = "def" ;
212my $x = 1 + $a ;
4438c4b7 213no warnings 'numeric' ;
0453d815 214my $z = 1 + $a ;
599cee73 215EXPECT
216Argument "def" isn't numeric in i_add at - line 4.
217########
218# sv.c
4438c4b7 219use warnings 'numeric' ;
599cee73 220my $x = 1 & "def" ;
4438c4b7 221no warnings 'numeric' ;
0453d815 222my $z = 1 & "def" ;
599cee73 223EXPECT
224Argument "def" isn't numeric in bit_and at - line 3.
225########
226# sv.c
4438c4b7 227use warnings 'redefine' ;
599cee73 228sub fred {}
229sub joe {}
230*fred = \&joe ;
4438c4b7 231no warnings 'redefine' ;
0453d815 232sub jim {}
233*jim = \&joe ;
599cee73 234EXPECT
235Subroutine fred redefined at - line 5.
236########
237# sv.c
4438c4b7 238use warnings 'printf' ;
3eeba6fb 239open F, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
cf2093f6 240printf F "%z\n" ;
241my $a = sprintf "%z" ;
599cee73 242printf F "%" ;
243$a = sprintf "%" ;
244printf F "%\x02" ;
245$a = sprintf "%\x02" ;
4438c4b7 246no warnings 'printf' ;
cf2093f6 247printf F "%z\n" ;
248$a = sprintf "%z" ;
0453d815 249printf F "%" ;
250$a = sprintf "%" ;
251printf F "%\x02" ;
252$a = sprintf "%\x02" ;
599cee73 253EXPECT
cf2093f6 254Invalid conversion in sprintf: "%z" at - line 5.
599cee73 255Invalid conversion in sprintf: end of string at - line 7.
256Invalid conversion in sprintf: "%\002" at - line 9.
cf2093f6 257Invalid conversion in printf: "%z" at - line 4.
599cee73 258Invalid conversion in printf: end of string at - line 6.
259Invalid conversion in printf: "%\002" at - line 8.
260########
261# sv.c
4438c4b7 262use warnings 'unsafe' ;
599cee73 263*a = undef ;
4438c4b7 264no warnings 'unsafe' ;
0453d815 265*b = undef ;
599cee73 266EXPECT
267Undefined value assigned to typeglob at - line 3.
0453d815 268########
269# sv.c
270use utf8 ;
271$^W =0 ;
272{
4438c4b7 273 use warnings 'utf8' ;
0453d815 274 my $a = rindex "a\xff bc ", "bc" ;
4438c4b7 275 no warnings 'utf8' ;
0453d815 276 $a = rindex "a\xff bc ", "bc" ;
277}
278my $a = rindex "a\xff bc ", "bc" ;
279EXPECT
280\xff will produce malformed UTF-8 character; use \x{ff} for that at - line 6.
281Malformed UTF-8 character at - line 6.
282Malformed UTF-8 character at - line 10.