summaryrefslogtreecommitdiff
path: root/t/lib/warnings/sv
blob: a9636e0cf793e20081083891ccb2de8d4a3fefff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
  sv.c	

  warn(warn_uninit);

  warn(warn_uninit);

  warn(warn_uninit);

  warn(warn_uninit);

  not_a_number(sv);

  not_a_number(sv);

  warn(warn_uninit);

  not_a_number(sv);

  warn(warn_uninit);

  not_a_number(sv);

  not_a_number(sv);

  warn(warn_uninit);

  warn(warn_uninit);

  Subroutine %s redefined	

  Invalid conversion in %s:

  Undefined value assigned to typeglob

  Reference is already weak			[Perl_sv_rvweaken] <<TODO

  Mandatory Warnings
  ------------------
  Malformed UTF-8 character [sv_pos_b2u] (not tested: difficult to produce
                                          with perl now)

  Mandatory Warnings TODO
  ------------------
    Attempt to free non-arena SV: 0x%lx		[del_sv]
    Reference miscount in sv_replace()		[sv_replace]
    Attempt to free unreferenced scalar		[sv_free]
    Attempt to free temp prematurely: SV 0x%lx	[sv_free]
    semi-panic: attempt to dup freed string	[newSVsv]
    

__END__
# sv.c
use integer ;
use warnings 'uninitialized' ;
$x = 1 + $a[0] ; # a
no warnings 'uninitialized' ;
$x = 1 + $b[0] ; # a
EXPECT
Use of uninitialized value $a[0] in integer addition (+) at - line 4.
########
# sv.c (sv_2iv)
package fred ;
sub TIESCALAR { my $x ; bless \$x}
sub FETCH { return undef }
sub STORE { return 1 }
package main ;
tie $A, 'fred' ;
use integer ;
use warnings 'uninitialized' ;
$A *= 2 ;
no warnings 'uninitialized' ;
$A *= 2 ;
EXPECT
Use of uninitialized value $A in integer multiplication (*) at - line 10.
########
# sv.c
use integer ;
use warnings 'uninitialized' ;
my $x *= 2 ; #b 
no warnings 'uninitialized' ;
my $y *= 2 ; #b 
EXPECT
Use of uninitialized value $x in integer multiplication (*) at - line 4.
########
# sv.c (sv_2uv)
package fred ;
sub TIESCALAR { my $x ; bless \$x}
sub FETCH { return undef }
sub STORE { return 1 }
package main ;
tie $A, 'fred' ;
use warnings 'uninitialized' ;
$B = 0 ;
$B |= $A ;
no warnings 'uninitialized' ;
$B = 0 ;
$B |= $A ;
EXPECT
Use of uninitialized value $A in bitwise or (|) at - line 10.
########
# sv.c
use warnings 'uninitialized' ;
my $Y = 1 ; 
my $x = 1 | $a[$Y] ;
no warnings 'uninitialized' ;
my $Y = 1 ; 
$x = 1 | $b[$Y] ;
EXPECT
Use of uninitialized value within @a in bitwise or (|) at - line 4.
########
# sv.c
use warnings 'uninitialized' ;
my $Y = 1 ; 
my $x = 1 & $a[$Y] ;
no warnings 'uninitialized' ;
my $Y = 1 ; 
$x = 1 & $b[$Y] ;
EXPECT
Use of uninitialized value within @a in bitwise and (&) at - line 4.
########
# sv.c
use warnings 'uninitialized' ;
my $Y = 1 ; 
my $x = ~$a[$Y] ;
no warnings 'uninitialized' ;
my $Y = 1 ; 
$x = ~$b[$Y] ;
EXPECT
Use of uninitialized value within @a in 1's complement (~) at - line 4.
########
# sv.c
use warnings 'uninitialized' ;
my $x *= 1 ; # d
no warnings 'uninitialized' ;
my $y *= 1 ; # d
EXPECT
Use of uninitialized value $x in multiplication (*) at - line 3.
########
# sv.c
use warnings 'uninitialized' ;
$x = 1 + $a[0] ; # e
no warnings 'uninitialized' ;
$x = 1 + $b[0] ; # e
EXPECT
Use of uninitialized value $a[0] in addition (+) at - line 3.
########
# sv.c (sv_2nv)
package fred ;
sub TIESCALAR { my $x ; bless \$x}
sub FETCH { return undef }
sub STORE { return 1 }
package main ;
tie $A, 'fred' ;
use warnings 'uninitialized' ;
$A *= 2 ;
no warnings 'uninitialized' ;
$A *= 2 ;
EXPECT
Use of uninitialized value $A in multiplication (*) at - line 9.
########
# sv.c
use warnings 'uninitialized' ;
$x = $y + 1 ; # f
no warnings 'uninitialized' ;
$x = $z + 1 ; # f
EXPECT
Use of uninitialized value $y in addition (+) at - line 3.
########
# sv.c
use warnings 'uninitialized' ;
$x = chop undef ; # g
no warnings 'uninitialized' ;
$x = chop undef ; # g
EXPECT
Modification of a read-only value attempted at - line 3.
########
# sv.c
use warnings 'uninitialized' ;
$x = chop $y ; # h
no warnings 'uninitialized' ;
$x = chop $z ; # h
EXPECT
Use of uninitialized value $y in scalar chop at - line 3.
########
# sv.c (sv_2pv)
package fred ;
sub TIESCALAR { my $x ; bless \$x}
sub FETCH { return undef }
sub STORE { return 1 }
package main ;
tie $A, 'fred' ;
use warnings 'uninitialized' ;
$B = "" ;
$B .= $A ;
no warnings 'uninitialized' ;
$C = "" ;
$C .= $A ;
EXPECT
Use of uninitialized value $A in concatenation (.) or string at - line 10.
########
# perlbug 20011116.125
use warnings 'uninitialized';
$a = undef;
$foo = join '', $a, "\n";
$foo = "$a\n";
$foo = "a:$a\n";
EXPECT
Use of uninitialized value $a in join or string at - line 4.
Use of uninitialized value $a in concatenation (.) or string at - line 5.
Use of uninitialized value $a in concatenation (.) or string at - line 6.
########
# sv.c 
use warnings 'numeric' ;
sub TIESCALAR{bless[]} ; 
sub FETCH {"def"} ; 
tie $a,"main" ; 
my $b = 1 + $a;
no warnings 'numeric' ;
my $c = 1 + $a;
EXPECT
Argument "def" isn't numeric in addition (+) at - line 6.
########
# sv.c
use warnings 'numeric' ;
my $x = 1 + "def" ;
no warnings 'numeric' ;
my $z = 1 + "def" ;
EXPECT
Argument "def" isn't numeric in addition (+) at - line 3.
########
# sv.c
use warnings 'numeric' ;
my $a = "def" ;
my $x = 1 + $a ;
no warnings 'numeric' ;
my $y = 1 + $a ;
EXPECT
Argument "def" isn't numeric in addition (+) at - line 4.
########
# sv.c
use warnings 'numeric' ; use integer ;
my $a = "def" ;
my $x = 1 + $a ;
no warnings 'numeric' ;
my $z = 1 + $a ;
EXPECT
Argument "def" isn't numeric in integer addition (+) at - line 4.
########
# sv.c
use warnings 'numeric' ;
my $x = 1 & "def" ;
no warnings 'numeric' ;
my $z = 1 & "def" ;
EXPECT
Argument "def" isn't numeric in bitwise and (&) at - line 3.
########
# sv.c
use warnings 'numeric' ;
my $x = pack i => "def" ;
no warnings 'numeric' ;
my $z = pack i => "def" ;
EXPECT
Argument "def" isn't numeric in pack at - line 3.
########
# sv.c
use warnings 'numeric' ; 
my $a = "d\0f" ;
my $x = 1 + $a ;
no warnings 'numeric' ;
my $z = 1 + $a ;
EXPECT
Argument "d\0f" isn't numeric in addition (+) at - line 4.
########
# sv.c
use warnings 'redefine' ;
sub fred {}  
sub joe {} 
*fred = \&joe ;
no warnings 'redefine' ;
sub jim {} 
*jim = \&joe ;
EXPECT
Subroutine main::fred redefined at - line 5.
########
# sv.c
use warnings 'printf' ;
open F, ">".($^O eq 'VMS'? 'NL:' : '/dev/null') ;
printf F "%z\n" ;
my $a = sprintf "%z" ;
printf F "%" ;
$a = sprintf "%" ;
printf F "%\x02" ;
$a = sprintf "%\x02" ;
no warnings 'printf' ;
printf F "%z\n" ;
$a = sprintf "%z" ;
printf F "%" ;
$a = sprintf "%" ;
printf F "%\x02" ;
$a = sprintf "%\x02" ;
EXPECT
Invalid conversion in sprintf: "%z" at - line 5.
Invalid conversion in sprintf: end of string at - line 7.
Invalid conversion in sprintf: "%\002" at - line 9.
Invalid conversion in printf: "%z" at - line 4.
Invalid conversion in printf: end of string at - line 6.
Invalid conversion in printf: "%\002" at - line 8.
########
# sv.c
use warnings 'misc' ;
*a = undef ;
no warnings 'misc' ;
*b = undef ;
EXPECT
Undefined value assigned to typeglob at - line 3.
########
# sv.c
use warnings 'numeric' ;
$a = "\x{100}\x{200}" * 42;
no warnings 'numeric' ;
$a = "\x{100}\x{200}" * 42;
EXPECT
Argument "\x{100}\x{200}" isn't numeric in multiplication (*) at - line 3.
########
# sv.c
use warnings 'numeric' ;
$a = "\x{100}\x{200}"; $a = -$a;
no warnings 'numeric' ;
$a = "\x{100}\x{200}"; $a = -$a;
EXPECT
Argument "\x{100}\x{200}" isn't numeric in negation (-) at - line 3.