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
332
333
334
|
pp_hot.c
print() on unopened filehandle abc [pp_print]
$f = $a = "abc" ; print $f $a
Filehandle %s opened only for input [pp_print]
print STDIN "abc" ;
Filehandle %s opened only for output [pp_print]
$a = <STDOUT> ;
print() on closed filehandle %s [pp_print]
close STDIN ; print STDIN "abc" ;
uninitialized [pp_rv2av]
my $a = undef ; my @b = @$a
uninitialized [pp_rv2hv]
my $a = undef ; my %b = %$a
Odd number of elements in hash list [pp_aassign]
%X = (1,2,3) ;
Reference found where even-sized list expected [pp_aassign]
$X = [ 1 ..3 ];
Filehandle %s opened only for output [Perl_do_readline]
open (FH, ">./xcv") ;
my $a = <FH> ;
glob failed (can't start child: %s) [Perl_do_readline] <<TODO
readline() on closed filehandle %s [Perl_do_readline]
close STDIN ; $a = <STDIN>;
readline() on closed filehandle %s [Perl_do_readline]
readline(NONESUCH);
glob failed (child exited with status %d%s) [Perl_do_readline] <<TODO
Deep recursion on subroutine \"%s\" [Perl_sub_crush_depth]
sub fred { fred() if $a++ < 200} fred()
Deep recursion on anonymous subroutine [Perl_sub_crush_depth]
$a = sub { &$a if $a++ < 200} &$a
Possible Y2K bug: about to append an integer to '19' [pp_concat]
$x = "19$yy\n";
Use of reference "%s" as array index [pp_aelem]
$x[\1]
__END__
# pp_hot.c [pp_print]
use warnings 'unopened' ;
$f = $a = "abc" ;
print $f $a;
no warnings 'unopened' ;
print $f $a;
use warnings;
no warnings 'unopened' ;
print $f $a;
EXPECT
print() on unopened filehandle abc at - line 4.
########
# pp_hot.c [pp_print]
use warnings 'io' ;
# There is no guarantee that STDOUT is output only, or STDIN input only.
# Certainly on some BSDs (at least FreeBSD, Darwin, BSDi) file descriptors
# 1 and 2 are opened read/write on the tty, and the IO layers may reflect this.
# So we must make our own file handle that is read only.
my $file = "./xcv" ; unlink $file ;
open (FH, ">$file") or die $! ;
close FH or die $! ;
die "There is no file $file" unless -f $file ;
open (FH, "<$file") or die $! ;
print FH "anc" ;
open(FOO, "<&FH") or die $! ;
print FOO "anc" ;
no warnings 'io' ;
print FH "anc" ;
print FOO "anc" ;
use warnings 'io' ;
print FH "anc" ;
print FOO "anc" ;
close (FH) or die $! ;
close (FOO) or die $! ;
unlink $file ;
EXPECT
Filehandle FH opened only for input at - line 12.
Filehandle FOO opened only for input at - line 14.
Filehandle FH opened only for input at - line 19.
Filehandle FOO opened only for input at - line 20.
########
# pp_hot.c [pp_print]
use warnings 'closed' ;
close STDIN ;
print STDIN "anc";
opendir STDIN, ".";
print STDIN "anc";
closedir STDIN;
no warnings 'closed' ;
print STDIN "anc";
opendir STDIN, ".";
print STDIN "anc";
use warnings;
no warnings 'closed' ;
print STDIN "anc";
EXPECT
print() on closed filehandle STDIN at - line 4.
print() on closed filehandle STDIN at - line 6.
(Are you trying to call print() on dirhandle STDIN?)
########
# pp_hot.c [pp_print]
# [ID 20020425.012] from Dave Steiner <steiner@bakerst.rutgers.edu>
# This goes segv on 5.7.3
use warnings 'closed' ;
my $fh = *STDOUT{IO};
close STDOUT or die "Can't close STDOUT";
print $fh "Shouldn't print anything, but shouldn't SEGV either\n";
EXPECT
print() on closed filehandle at - line 7.
########
# pp_hot.c [pp_print]
package foo;
use warnings 'closed';
open my $fh1, "nonexistent";
print $fh1 42;
open $fh2, "nonexistent";
print $fh2 42;
open $bar::fh3, "nonexistent";
print $bar::fh3 42;
open bar::FH4, "nonexistent";
print bar::FH4 42;
EXPECT
print() on closed filehandle $fh1 at - line 5.
print() on closed filehandle $fh2 at - line 7.
print() on closed filehandle $fh3 at - line 9.
print() on closed filehandle FH4 at - line 11.
########
# pp_hot.c [pp_rv2av]
use warnings 'uninitialized' ;
my $a = undef ;
my @b = @$a;
no warnings 'uninitialized' ;
my @c = @$a;
EXPECT
Use of uninitialized value $a in array dereference at - line 4.
########
# pp_hot.c [pp_rv2hv]
use warnings 'uninitialized' ;
my $a = undef ;
my %b = %$a;
no warnings 'uninitialized' ;
my %c = %$a;
EXPECT
Use of uninitialized value $a in hash dereference at - line 4.
########
# pp_hot.c [pp_aassign]
use warnings 'misc' ;
my %X ; %X = (1,2,3) ;
no warnings 'misc' ;
my %Y ; %Y = (1,2,3) ;
EXPECT
Odd number of elements in hash assignment at - line 3.
########
# pp_hot.c [pp_aassign]
use warnings 'misc' ;
my %X ; %X = [1 .. 3] ;
no warnings 'misc' ;
my %Y ; %Y = [1 .. 3] ;
EXPECT
Reference found where even-sized list expected at - line 3.
########
# pp_hot.c [Perl_do_readline]
use warnings 'closed' ;
close STDIN ; $a = <STDIN> ;
opendir STDIN, "." ; $a = <STDIN> ;
closedir STDIN;
no warnings 'closed' ;
opendir STDIN, "." ; $a = <STDIN> ;
$a = <STDIN> ;
EXPECT
readline() on closed filehandle STDIN at - line 3.
readline() on closed filehandle STDIN at - line 4.
(Are you trying to call readline() on dirhandle STDIN?)
########
# pp_hot.c [Perl_do_readline]
use warnings 'io' ;
my $file = "./xcv" ; unlink $file ;
open (FH, ">$file") or die $! ;
my $a = <FH> ;
no warnings 'io' ;
$a = <FH> ;
use warnings 'io' ;
open(FOO, ">&FH") or die $! ;
$a = <FOO> ;
no warnings 'io' ;
$a = <FOO> ;
use warnings 'io' ;
$a = <FOO> ;
$a = <FH> ;
close (FH) or die $! ;
close (FOO) or die $! ;
unlink $file ;
EXPECT
Filehandle FH opened only for output at - line 5.
Filehandle FOO opened only for output at - line 10.
Filehandle FOO opened only for output at - line 14.
Filehandle FH opened only for output at - line 15.
########
# pp_hot.c [Perl_sub_crush_depth]
use warnings 'recursion' ;
sub fred
{
fred() if $a++ < 200
}
{
local $SIG{__WARN__} = sub {
die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
};
fred();
}
EXPECT
ok
########
# pp_hot.c [Perl_sub_crush_depth]
no warnings 'recursion' ;
sub fred
{
fred() if $a++ < 200
}
{
local $SIG{__WARN__} = sub {
die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/
};
fred();
}
EXPECT
########
# pp_hot.c [Perl_sub_crush_depth]
use warnings 'recursion' ;
$b = sub
{
&$b if $a++ < 200
} ;
&$b ;
EXPECT
Deep recursion on anonymous subroutine at - line 5.
########
# pp_hot.c [Perl_sub_crush_depth]
no warnings 'recursion' ;
$b = sub
{
&$b if $a++ < 200
} ;
&$b ;
EXPECT
########
# pp_hot.c [pp_concat]
use warnings 'uninitialized';
my($x, $y);
sub a { shift }
a($x . "x"); # should warn once
a($x . $y); # should warn twice
$x .= $y; # should warn once
$y .= $y; # should warn once
EXPECT
Use of uninitialized value $x in concatenation (.) or string at - line 5.
Use of uninitialized value $y in concatenation (.) or string at - line 6.
Use of uninitialized value $x in concatenation (.) or string at - line 6.
Use of uninitialized value $y in concatenation (.) or string at - line 7.
Use of uninitialized value $y in concatenation (.) or string at - line 8.
########
# pp_hot.c [pp_concat]
use warnings 'y2k';
use Config;
BEGIN {
unless ($Config{ccflags} =~ /Y2KWARN/) {
print "SKIPPED\n# perl not built with -DPERL_Y2KWARN";
exit 0;
}
}
my $x;
my $yy = 78;
$x = "19$yy\n";
$x = "19" . $yy . "\n";
$x = "319$yy\n";
$x = "319" . $yy . "\n";
$yy = 19;
$x = "ok $yy\n";
$yy = 9;
$x = 1 . $yy;
no warnings 'y2k';
$x = "19$yy\n";
$x = "19" . $yy . "\n";
EXPECT
Possible Y2K bug: about to append an integer to '19' at - line 12.
Possible Y2K bug: about to append an integer to '19' at - line 13.
########
# pp_hot.c [pp_aelem]
{
use warnings 'misc';
print $x[\1];
}
{
no warnings 'misc';
print $x[\1];
}
EXPECT
OPTION regex
Use of reference ".*" as array index at - line 4.
########
# pp_hot.c [pp_aelem]
package Foo;use overload q("") => sub {};package main;$a = bless {}, "Foo";
$b = {};
{
use warnings 'misc';
print $x[$a];
print $x[$b];
}
{
no warnings 'misc';
print $x[$a];
print $x[$b];
}
EXPECT
OPTION regex
Use of reference ".*" as array index at - line 7.
|