This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
sv_uni_display(): do not add the "...", let the caller
[perl5.git] / t / lib / warnings / 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
6bc102ca
GS
35 Possible Y2K bug: %d format string following '19'
36
767a6a26
PM
37 Reference is already weak [Perl_sv_rvweaken] <<TODO
38
0453d815
PM
39 Mandatory Warnings
40 ------------------
7e2040f0
GS
41 Malformed UTF-8 character [sv_pos_b2u] (not tested: difficult to produce
42 with perl now)
0453d815
PM
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
PM
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
PM
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
PM
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
PM
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
PM
95$B = 0 ;
96$B |= $A ;
4438c4b7 97no warnings 'uninitialized' ;
0453d815
PM
98$B = 0 ;
99$B |= $A ;
599cee73 100EXPECT
b89fed5f 101Use of uninitialized value in bitwise or (|) at - line 10.
599cee73
PM
102########
103# sv.c
4438c4b7 104use warnings 'uninitialized' ;
599cee73 105my $Y = 1 ;
0453d815 106my $x = 1 | $a[$Y] ;
4438c4b7 107no warnings 'uninitialized' ;
0453d815
PM
108my $Y = 1 ;
109$x = 1 | $b[$Y] ;
599cee73 110EXPECT
b89fed5f 111Use of uninitialized value in bitwise or (|) at - line 4.
599cee73
PM
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
PM
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
PM
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
PM
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
PM
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
PM
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
PM
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
PM
175$B = "" ;
176$B .= $A ;
4438c4b7 177no warnings 'uninitialized' ;
0453d815
PM
178$C = "" ;
179$C .= $A ;
599cee73 180EXPECT
297b36dc 181Use of uninitialized value in concatenation (.) or string at - line 10.
599cee73
PM
182########
183# sv.c
4438c4b7 184use warnings 'numeric' ;
599cee73
PM
185sub TIESCALAR{bless[]} ;
186sub FETCH {"def"} ;
187tie $a,"main" ;
0453d815 188my $b = 1 + $a;
4438c4b7 189no warnings 'numeric' ;
0453d815 190my $c = 1 + $a;
599cee73 191EXPECT
42d38218 192Argument "def" isn't numeric in addition (+) at - line 6.
599cee73
PM
193########
194# sv.c
4438c4b7 195use warnings 'numeric' ;
599cee73 196my $x = 1 + "def" ;
4438c4b7 197no warnings 'numeric' ;
0453d815 198my $z = 1 + "def" ;
599cee73 199EXPECT
42d38218 200Argument "def" isn't numeric in addition (+) at - line 3.
599cee73
PM
201########
202# sv.c
4438c4b7 203use warnings 'numeric' ;
599cee73
PM
204my $a = "def" ;
205my $x = 1 + $a ;
4438c4b7 206no warnings 'numeric' ;
0453d815 207my $y = 1 + $a ;
599cee73 208EXPECT
42d38218 209Argument "def" isn't numeric in addition (+) at - line 4.
599cee73
PM
210########
211# sv.c
4438c4b7 212use warnings 'numeric' ; use integer ;
599cee73
PM
213my $a = "def" ;
214my $x = 1 + $a ;
4438c4b7 215no warnings 'numeric' ;
0453d815 216my $z = 1 + $a ;
599cee73 217EXPECT
42d38218 218Argument "def" isn't numeric in integer addition (+) at - line 4.
599cee73
PM
219########
220# sv.c
4438c4b7 221use warnings 'numeric' ;
599cee73 222my $x = 1 & "def" ;
4438c4b7 223no warnings 'numeric' ;
0453d815 224my $z = 1 & "def" ;
599cee73 225EXPECT
42d38218 226Argument "def" isn't numeric in bitwise and (&) at - line 3.
599cee73
PM
227########
228# sv.c
59bb5845
RB
229use warnings 'numeric' ;
230my $x = pack i => "def" ;
231no warnings 'numeric' ;
232my $z = pack i => "def" ;
233EXPECT
234Argument "def" isn't numeric in pack at - line 3.
235########
236# sv.c
237use warnings 'numeric' ;
238my $a = "d\0f" ;
239my $x = 1 + $a ;
240no warnings 'numeric' ;
241my $z = 1 + $a ;
242EXPECT
243Argument "d\0f" isn't numeric in addition (+) at - line 4.
244########
245# sv.c
4438c4b7 246use warnings 'redefine' ;
599cee73
PM
247sub fred {}
248sub joe {}
249*fred = \&joe ;
4438c4b7 250no warnings 'redefine' ;
0453d815
PM
251sub jim {}
252*jim = \&joe ;
599cee73
PM
253EXPECT
254Subroutine fred redefined at - line 5.
255########
256# sv.c
4438c4b7 257use warnings 'printf' ;
3eeba6fb 258open F, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
cf2093f6
JH
259printf F "%z\n" ;
260my $a = sprintf "%z" ;
599cee73
PM
261printf F "%" ;
262$a = sprintf "%" ;
263printf F "%\x02" ;
264$a = sprintf "%\x02" ;
4438c4b7 265no warnings 'printf' ;
cf2093f6
JH
266printf F "%z\n" ;
267$a = sprintf "%z" ;
0453d815
PM
268printf F "%" ;
269$a = sprintf "%" ;
270printf F "%\x02" ;
271$a = sprintf "%\x02" ;
599cee73 272EXPECT
cf2093f6 273Invalid conversion in sprintf: "%z" at - line 5.
599cee73
PM
274Invalid conversion in sprintf: end of string at - line 7.
275Invalid conversion in sprintf: "%\002" at - line 9.
cf2093f6 276Invalid conversion in printf: "%z" at - line 4.
599cee73
PM
277Invalid conversion in printf: end of string at - line 6.
278Invalid conversion in printf: "%\002" at - line 8.
279########
280# sv.c
e476b1b5 281use warnings 'misc' ;
599cee73 282*a = undef ;
e476b1b5 283no warnings 'misc' ;
0453d815 284*b = undef ;
599cee73
PM
285EXPECT
286Undefined value assigned to typeglob at - line 3.
0453d815
PM
287########
288# sv.c
e476b1b5 289use warnings 'y2k';
6bc102ca
GS
290use Config;
291BEGIN {
292 unless ($Config{ccflags} =~ /Y2KWARN/) {
293 print "SKIPPED\n# perl not built with -DPERL_Y2KWARN";
294 exit 0;
295 }
296 $|=1;
297}
298my $x;
299my $yy = 78;
300$x = printf "19%02d\n", $yy;
301$x = sprintf "#19%02d\n", $yy;
302$x = printf " 19%02d\n", 78;
303$x = sprintf "19%02d\n", 78;
304$x = printf "319%02d\n", $yy;
305$x = sprintf "319%02d\n", $yy;
e476b1b5 306no warnings 'y2k';
6bc102ca
GS
307$x = printf "19%02d\n", $yy;
308$x = sprintf "19%02d\n", $yy;
309$x = printf "19%02d\n", 78;
310$x = sprintf "19%02d\n", 78;
311EXPECT
312Possible Y2K bug: %d format string following '19' at - line 16.
313Possible Y2K bug: %d format string following '19' at - line 13.
3141978
315Possible Y2K bug: %d format string following '19' at - line 14.
316Possible Y2K bug: %d format string following '19' at - line 15.
317 1978
31831978
3191978
3201978