This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Undo #3790 and the patches that attempted to fix it
[perl5.git] / t / pragma / warn / sv
CommitLineData
0453d815 1 sv.c
599cee73
PM
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
0453d815
PM
35 Mandatory Warnings
36 ------------------
37 Malformed UTF-8 character [sv_pos_b2u]
38 my $a = rindex "a\xff bc ", "bc" ;
39
40 Mandatory Warnings TODO
41 ------------------
42 Attempt to free non-arena SV: 0x%lx [del_sv]
43 Reference miscount in sv_replace() [sv_replace]
44 Attempt to free unreferenced scalar [sv_free]
45 Attempt to free temp prematurely: SV 0x%lx [sv_free]
46 semi-panic: attempt to dup freed string [newSVsv]
47
599cee73
PM
48
49__END__
50# sv.c
51use integer ;
52use warning 'uninitialized' ;
53$x = 1 + $a[0] ; # a
0453d815
PM
54no warning 'uninitialized' ;
55$x = 1 + $b[0] ; # a
599cee73
PM
56EXPECT
57Use of uninitialized value at - line 4.
58########
59# sv.c (sv_2iv)
60package fred ;
61sub TIESCALAR { my $x ; bless \$x}
62sub FETCH { return undef }
63sub STORE { return 1 }
64package main ;
65tie $A, 'fred' ;
66use integer ;
67use warning 'uninitialized' ;
68$A *= 2 ;
0453d815
PM
69no warning 'uninitialized' ;
70$A *= 2 ;
599cee73
PM
71EXPECT
72Use of uninitialized value at - line 10.
73########
74# sv.c
75use integer ;
76use warning 'uninitialized' ;
77my $x *= 2 ; #b
0453d815
PM
78no warning 'uninitialized' ;
79my $y *= 2 ; #b
599cee73
PM
80EXPECT
81Use of uninitialized value at - line 4.
82########
83# sv.c (sv_2uv)
84package fred ;
85sub TIESCALAR { my $x ; bless \$x}
86sub FETCH { return undef }
87sub STORE { return 1 }
88package main ;
89tie $A, 'fred' ;
90use warning 'uninitialized' ;
91$B = 0 ;
92$B |= $A ;
0453d815
PM
93no warning 'uninitialized' ;
94$B = 0 ;
95$B |= $A ;
599cee73
PM
96EXPECT
97Use of uninitialized value at - line 10.
98########
99# sv.c
100use warning 'uninitialized' ;
101my $Y = 1 ;
0453d815
PM
102my $x = 1 | $a[$Y] ;
103no warning 'uninitialized' ;
104my $Y = 1 ;
105$x = 1 | $b[$Y] ;
599cee73
PM
106EXPECT
107Use of uninitialized value at - line 4.
108########
109# sv.c
110use warning 'uninitialized' ;
111my $x *= 1 ; # d
0453d815
PM
112no warning 'uninitialized' ;
113my $y *= 1 ; # d
599cee73
PM
114EXPECT
115Use of uninitialized value at - line 3.
116########
117# sv.c
118use warning 'uninitialized' ;
119$x = 1 + $a[0] ; # e
0453d815
PM
120no warning 'uninitialized' ;
121$x = 1 + $b[0] ; # e
599cee73
PM
122EXPECT
123Use of uninitialized value at - line 3.
124########
125# sv.c (sv_2nv)
126package fred ;
127sub TIESCALAR { my $x ; bless \$x}
128sub FETCH { return undef }
129sub STORE { return 1 }
130package main ;
131tie $A, 'fred' ;
132use warning 'uninitialized' ;
133$A *= 2 ;
0453d815
PM
134no warning 'uninitialized' ;
135$A *= 2 ;
599cee73
PM
136EXPECT
137Use of uninitialized value at - line 9.
138########
139# sv.c
140use warning 'uninitialized' ;
141$x = $y + 1 ; # f
0453d815
PM
142no warning 'uninitialized' ;
143$x = $z + 1 ; # f
599cee73
PM
144EXPECT
145Use of uninitialized value at - line 3.
146########
147# sv.c
148use warning 'uninitialized' ;
149$x = chop undef ; # g
0453d815
PM
150no warning 'uninitialized' ;
151$x = chop undef ; # g
599cee73 152EXPECT
b0c98cec 153Modification of a read-only value attempted at - line 3.
599cee73
PM
154########
155# sv.c
156use warning 'uninitialized' ;
157$x = chop $y ; # h
0453d815
PM
158no warning 'uninitialized' ;
159$x = chop $z ; # h
599cee73
PM
160EXPECT
161Use of uninitialized value at - line 3.
162########
163# sv.c (sv_2pv)
164package fred ;
165sub TIESCALAR { my $x ; bless \$x}
166sub FETCH { return undef }
167sub STORE { return 1 }
168package main ;
169tie $A, 'fred' ;
170use warning 'uninitialized' ;
171$B = "" ;
172$B .= $A ;
0453d815
PM
173no warning 'uninitialized' ;
174$C = "" ;
175$C .= $A ;
599cee73
PM
176EXPECT
177Use of uninitialized value at - line 10.
178########
179# sv.c
180use warning 'numeric' ;
181sub TIESCALAR{bless[]} ;
182sub FETCH {"def"} ;
183tie $a,"main" ;
0453d815
PM
184my $b = 1 + $a;
185no warning 'numeric' ;
186my $c = 1 + $a;
599cee73
PM
187EXPECT
188Argument "def" isn't numeric in add at - line 6.
189########
190# sv.c
191use warning 'numeric' ;
192my $x = 1 + "def" ;
0453d815
PM
193no warning 'numeric' ;
194my $z = 1 + "def" ;
599cee73
PM
195EXPECT
196Argument "def" isn't numeric in add at - line 3.
197########
198# sv.c
199use warning 'numeric' ;
200my $a = "def" ;
201my $x = 1 + $a ;
0453d815
PM
202no warning 'numeric' ;
203my $y = 1 + $a ;
599cee73
PM
204EXPECT
205Argument "def" isn't numeric in add at - line 4.
206########
207# sv.c
208use warning 'numeric' ; use integer ;
209my $a = "def" ;
210my $x = 1 + $a ;
0453d815
PM
211no warning 'numeric' ;
212my $z = 1 + $a ;
599cee73
PM
213EXPECT
214Argument "def" isn't numeric in i_add at - line 4.
215########
216# sv.c
217use warning 'numeric' ;
218my $x = 1 & "def" ;
0453d815
PM
219no warning 'numeric' ;
220my $z = 1 & "def" ;
599cee73
PM
221EXPECT
222Argument "def" isn't numeric in bit_and at - line 3.
223########
224# sv.c
225use warning 'redefine' ;
226sub fred {}
227sub joe {}
228*fred = \&joe ;
0453d815
PM
229no warning 'redefine' ;
230sub jim {}
231*jim = \&joe ;
599cee73
PM
232EXPECT
233Subroutine fred redefined at - line 5.
234########
235# sv.c
236use warning 'printf' ;
3eeba6fb 237open F, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
599cee73
PM
238printf F "%q\n" ;
239my $a = sprintf "%q" ;
240printf F "%" ;
241$a = sprintf "%" ;
242printf F "%\x02" ;
243$a = sprintf "%\x02" ;
0453d815
PM
244no warning 'printf' ;
245printf F "%q\n" ;
246$a = sprintf "%q" ;
247printf F "%" ;
248$a = sprintf "%" ;
249printf F "%\x02" ;
250$a = sprintf "%\x02" ;
599cee73
PM
251EXPECT
252Invalid conversion in sprintf: "%q" at - line 5.
253Invalid conversion in sprintf: end of string at - line 7.
254Invalid conversion in sprintf: "%\002" at - line 9.
255Invalid conversion in printf: "%q" at - line 4.
256Invalid conversion in printf: end of string at - line 6.
257Invalid conversion in printf: "%\002" at - line 8.
258########
259# sv.c
260use warning 'unsafe' ;
261*a = undef ;
0453d815
PM
262no warning 'unsafe' ;
263*b = undef ;
599cee73
PM
264EXPECT
265Undefined value assigned to typeglob at - line 3.
0453d815
PM
266########
267# sv.c
268use utf8 ;
269$^W =0 ;
270{
271 use warning 'utf8' ;
272 my $a = rindex "a\xff bc ", "bc" ;
273 no warning 'utf8' ;
274 $a = rindex "a\xff bc ", "bc" ;
275}
276my $a = rindex "a\xff bc ", "bc" ;
277EXPECT
278\xff will produce malformed UTF-8 character; use \x{ff} for that at - line 6.
279Malformed UTF-8 character at - line 6.
280Malformed UTF-8 character at - line 10.