Commit | Line | Data |
767a6a26 |
1 | pp_hot.c |
599cee73 |
2 | |
2dd78f96 |
3 | print() on unopened filehandle abc [pp_print] |
599cee73 |
4 | $f = $a = "abc" ; print $f $a |
5 | |
767a6a26 |
6 | Filehandle %s opened only for input [pp_print] |
599cee73 |
7 | print STDIN "abc" ; |
8 | |
767a6a26 |
9 | Filehandle %s opened only for output [pp_print] |
977289e4 |
10 | $a = <STDOUT> ; |
599cee73 |
11 | |
9a7dcd9c |
12 | print() on closed filehandle %s [pp_print] |
599cee73 |
13 | close STDIN ; print STDIN "abc" ; |
14 | |
767a6a26 |
15 | uninitialized [pp_rv2av] |
599cee73 |
16 | my $a = undef ; my @b = @$a |
17 | |
767a6a26 |
18 | uninitialized [pp_rv2hv] |
599cee73 |
19 | my $a = undef ; my %b = %$a |
20 | |
767a6a26 |
21 | Odd number of elements in hash list [pp_aassign] |
599cee73 |
22 | %X = (1,2,3) ; |
23 | |
767a6a26 |
24 | Reference found where even-sized list expected [pp_aassign] |
599cee73 |
25 | $X = [ 1 ..3 ]; |
26 | |
767a6a26 |
27 | Filehandle %s opened only for output [Perl_do_readline] |
28 | open (FH, ">./xcv") ; |
29 | my $a = <FH> ; |
30 | |
31 | glob failed (can't start child: %s) [Perl_do_readline] <<TODO |
32 | |
9a7dcd9c |
33 | readline() on closed filehandle %s [Perl_do_readline] |
599cee73 |
34 | close STDIN ; $a = <STDIN>; |
35 | |
790090df |
36 | readline() on closed filehandle %s [Perl_do_readline] |
37 | readline(NONESUCH); |
38 | |
767a6a26 |
39 | glob failed (child exited with status %d%s) [Perl_do_readline] <<TODO |
40 | |
41 | Deep recursion on subroutine \"%s\" [Perl_sub_crush_depth] |
6bc102ca |
42 | sub fred { fred() if $a++ < 200} fred() |
599cee73 |
43 | |
767a6a26 |
44 | Deep recursion on anonymous subroutine [Perl_sub_crush_depth] |
6bc102ca |
45 | $a = sub { &$a if $a++ < 200} &$a |
599cee73 |
46 | |
6bc102ca |
47 | Possible Y2K bug: about to append an integer to '19' [pp_concat] |
48 | $x = "19$yy\n"; |
767a6a26 |
49 | |
d804643f |
50 | Use of reference "%s" as array index [pp_aelem] |
51 | $x[\1] |
52 | |
599cee73 |
53 | __END__ |
767a6a26 |
54 | # pp_hot.c [pp_print] |
4438c4b7 |
55 | use warnings 'unopened' ; |
599cee73 |
56 | $f = $a = "abc" ; |
0453d815 |
57 | print $f $a; |
4438c4b7 |
58 | no warnings 'unopened' ; |
0453d815 |
59 | print $f $a; |
cf26e47f |
60 | use warnings; |
61 | no warnings 'unopened' ; |
62 | print $f $a; |
599cee73 |
63 | EXPECT |
2dd78f96 |
64 | print() on unopened filehandle abc at - line 4. |
599cee73 |
65 | ######## |
767a6a26 |
66 | # pp_hot.c [pp_print] |
4438c4b7 |
67 | use warnings 'io' ; |
977289e4 |
68 | # There is no guarantee that STDOUT is output only, or STDIN input only. |
69 | # Certainly on some BSDs (at least FreeBSD, Darwin, BSDi) file descriptors |
70 | # 1 and 2 are opened read/write on the tty, and the IO layers may reflect this. |
71 | # So we must make our own file handle that is read only. |
72 | my $file = "./xcv" ; unlink $file ; |
73 | open (FH, ">$file") or die $! ; |
74 | close FH or die $! ; |
75 | die "There is no file $file" unless -f $file ; |
76 | open (FH, "<$file") or die $! ; |
77 | print FH "anc" ; |
78 | open(FOO, "<&FH") or die $! ; |
79 | print FOO "anc" ; |
37bd1396 |
80 | no warnings 'io' ; |
977289e4 |
81 | print FH "anc" ; |
82 | print FOO "anc" ; |
83 | use warnings 'io' ; |
84 | print FH "anc" ; |
85 | print FOO "anc" ; |
86 | close (FH) or die $! ; |
87 | close (FOO) or die $! ; |
88 | unlink $file ; |
599cee73 |
89 | EXPECT |
977289e4 |
90 | Filehandle FH opened only for input at - line 12. |
91 | Filehandle FOO opened only for input at - line 14. |
92 | Filehandle FH opened only for input at - line 19. |
93 | Filehandle FOO opened only for input at - line 20. |
599cee73 |
94 | ######## |
767a6a26 |
95 | # pp_hot.c [pp_print] |
4438c4b7 |
96 | use warnings 'closed' ; |
599cee73 |
97 | close STDIN ; |
98 | print STDIN "anc"; |
69282e91 |
99 | opendir STDIN, "."; |
100 | print STDIN "anc"; |
101 | closedir STDIN; |
4438c4b7 |
102 | no warnings 'closed' ; |
0453d815 |
103 | print STDIN "anc"; |
69282e91 |
104 | opendir STDIN, "."; |
105 | print STDIN "anc"; |
cf26e47f |
106 | use warnings; |
107 | no warnings 'closed' ; |
108 | print STDIN "anc"; |
599cee73 |
109 | EXPECT |
43693395 |
110 | print() on closed filehandle STDIN at - line 4. |
111 | print() on closed filehandle STDIN at - line 6. |
112 | (Are you trying to call print() on dirhandle STDIN?) |
599cee73 |
113 | ######## |
f55e507d |
114 | # pp_hot.c [pp_print] |
115 | # [ID 20020425.012] from Dave Steiner <steiner@bakerst.rutgers.edu> |
116 | # This goes segv on 5.7.3 |
117 | use warnings 'closed' ; |
118 | my $fh = *STDOUT{IO}; |
119 | close STDOUT or die "Can't close STDOUT"; |
120 | print $fh "Shouldn't print anything, but shouldn't SEGV either\n"; |
121 | EXPECT |
122 | print() on closed filehandle at - line 7. |
123 | ######## |
f62cb720 |
124 | # pp_hot.c [pp_print] |
125 | package foo; |
126 | use warnings 'closed'; |
127 | open my $fh1, "nonexistent"; |
128 | print $fh1 42; |
129 | open $fh2, "nonexistent"; |
130 | print $fh2 42; |
131 | open $bar::fh3, "nonexistent"; |
132 | print $bar::fh3 42; |
133 | open bar::FH4, "nonexistent"; |
134 | print bar::FH4 42; |
135 | EXPECT |
136 | print() on closed filehandle $fh1 at - line 5. |
137 | print() on closed filehandle $fh2 at - line 7. |
138 | print() on closed filehandle $fh3 at - line 9. |
139 | print() on closed filehandle FH4 at - line 11. |
140 | ######## |
767a6a26 |
141 | # pp_hot.c [pp_rv2av] |
4438c4b7 |
142 | use warnings 'uninitialized' ; |
599cee73 |
143 | my $a = undef ; |
0453d815 |
144 | my @b = @$a; |
4438c4b7 |
145 | no warnings 'uninitialized' ; |
0453d815 |
146 | my @c = @$a; |
599cee73 |
147 | EXPECT |
b89fed5f |
148 | Use of uninitialized value in array dereference at - line 4. |
599cee73 |
149 | ######## |
767a6a26 |
150 | # pp_hot.c [pp_rv2hv] |
4438c4b7 |
151 | use warnings 'uninitialized' ; |
599cee73 |
152 | my $a = undef ; |
0453d815 |
153 | my %b = %$a; |
4438c4b7 |
154 | no warnings 'uninitialized' ; |
0453d815 |
155 | my %c = %$a; |
599cee73 |
156 | EXPECT |
b89fed5f |
157 | Use of uninitialized value in hash dereference at - line 4. |
599cee73 |
158 | ######## |
767a6a26 |
159 | # pp_hot.c [pp_aassign] |
e476b1b5 |
160 | use warnings 'misc' ; |
599cee73 |
161 | my %X ; %X = (1,2,3) ; |
e476b1b5 |
162 | no warnings 'misc' ; |
0453d815 |
163 | my %Y ; %Y = (1,2,3) ; |
599cee73 |
164 | EXPECT |
165 | Odd number of elements in hash assignment at - line 3. |
166 | ######## |
767a6a26 |
167 | # pp_hot.c [pp_aassign] |
e476b1b5 |
168 | use warnings 'misc' ; |
599cee73 |
169 | my %X ; %X = [1 .. 3] ; |
e476b1b5 |
170 | no warnings 'misc' ; |
0453d815 |
171 | my %Y ; %Y = [1 .. 3] ; |
599cee73 |
172 | EXPECT |
173 | Reference found where even-sized list expected at - line 3. |
174 | ######## |
767a6a26 |
175 | # pp_hot.c [Perl_do_readline] |
4438c4b7 |
176 | use warnings 'closed' ; |
69282e91 |
177 | close STDIN ; $a = <STDIN> ; |
178 | opendir STDIN, "." ; $a = <STDIN> ; |
179 | closedir STDIN; |
4438c4b7 |
180 | no warnings 'closed' ; |
69282e91 |
181 | opendir STDIN, "." ; $a = <STDIN> ; |
0453d815 |
182 | $a = <STDIN> ; |
599cee73 |
183 | EXPECT |
43693395 |
184 | readline() on closed filehandle STDIN at - line 3. |
185 | readline() on closed filehandle STDIN at - line 4. |
186 | (Are you trying to call readline() on dirhandle STDIN?) |
599cee73 |
187 | ######## |
767a6a26 |
188 | # pp_hot.c [Perl_do_readline] |
189 | use warnings 'io' ; |
190 | my $file = "./xcv" ; unlink $file ; |
977289e4 |
191 | open (FH, ">$file") or die $! ; |
767a6a26 |
192 | my $a = <FH> ; |
193 | no warnings 'io' ; |
194 | $a = <FH> ; |
977289e4 |
195 | use warnings 'io' ; |
196 | open(FOO, ">&FH") or die $! ; |
197 | $a = <FOO> ; |
198 | no warnings 'io' ; |
199 | $a = <FOO> ; |
200 | use warnings 'io' ; |
201 | $a = <FOO> ; |
202 | $a = <FH> ; |
203 | close (FH) or die $! ; |
204 | close (FOO) or die $! ; |
767a6a26 |
205 | unlink $file ; |
206 | EXPECT |
43693395 |
207 | Filehandle FH opened only for output at - line 5. |
977289e4 |
208 | Filehandle FOO opened only for output at - line 10. |
209 | Filehandle FOO opened only for output at - line 14. |
210 | Filehandle FH opened only for output at - line 15. |
767a6a26 |
211 | ######## |
212 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
213 | use warnings 'recursion' ; |
599cee73 |
214 | sub fred |
215 | { |
216 | fred() if $a++ < 200 |
217 | } |
4a925ff6 |
218 | { |
219 | local $SIG{__WARN__} = sub { |
220 | die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ |
221 | }; |
222 | fred(); |
223 | } |
599cee73 |
224 | EXPECT |
4a925ff6 |
225 | ok |
599cee73 |
226 | ######## |
767a6a26 |
227 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
228 | no warnings 'recursion' ; |
0453d815 |
229 | sub fred |
230 | { |
231 | fred() if $a++ < 200 |
232 | } |
233 | { |
234 | local $SIG{__WARN__} = sub { |
235 | die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ |
236 | }; |
237 | fred(); |
238 | } |
239 | EXPECT |
240 | |
241 | ######## |
767a6a26 |
242 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
243 | use warnings 'recursion' ; |
599cee73 |
244 | $b = sub |
245 | { |
246 | &$b if $a++ < 200 |
247 | } ; |
248 | |
249 | &$b ; |
250 | EXPECT |
251 | Deep recursion on anonymous subroutine at - line 5. |
0453d815 |
252 | ######## |
767a6a26 |
253 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
254 | no warnings 'recursion' ; |
0453d815 |
255 | $b = sub |
256 | { |
257 | &$b if $a++ < 200 |
258 | } ; |
259 | |
260 | &$b ; |
261 | EXPECT |
6bc102ca |
262 | ######## |
263 | # pp_hot.c [pp_concat] |
8d6d96c1 |
264 | use warnings 'uninitialized'; |
265 | my($x, $y); |
266 | sub a { shift } |
267 | a($x . "x"); # should warn once |
268 | a($x . $y); # should warn twice |
269 | $x .= $y; # should warn once |
270 | $y .= $y; # should warn once |
271 | EXPECT |
272 | Use of uninitialized value in concatenation (.) or string at - line 5. |
273 | Use of uninitialized value in concatenation (.) or string at - line 6. |
274 | Use of uninitialized value in concatenation (.) or string at - line 6. |
275 | Use of uninitialized value in concatenation (.) or string at - line 7. |
276 | Use of uninitialized value in concatenation (.) or string at - line 8. |
277 | ######## |
278 | # pp_hot.c [pp_concat] |
e476b1b5 |
279 | use warnings 'y2k'; |
6bc102ca |
280 | use Config; |
281 | BEGIN { |
282 | unless ($Config{ccflags} =~ /Y2KWARN/) { |
283 | print "SKIPPED\n# perl not built with -DPERL_Y2KWARN"; |
284 | exit 0; |
285 | } |
286 | } |
287 | my $x; |
288 | my $yy = 78; |
289 | $x = "19$yy\n"; |
290 | $x = "19" . $yy . "\n"; |
291 | $x = "319$yy\n"; |
292 | $x = "319" . $yy . "\n"; |
777b0c87 |
293 | $yy = 19; |
294 | $x = "ok $yy\n"; |
295 | $yy = 9; |
296 | $x = 1 . $yy; |
e476b1b5 |
297 | no warnings 'y2k'; |
6bc102ca |
298 | $x = "19$yy\n"; |
299 | $x = "19" . $yy . "\n"; |
300 | EXPECT |
301 | Possible Y2K bug: about to append an integer to '19' at - line 12. |
302 | Possible Y2K bug: about to append an integer to '19' at - line 13. |
d804643f |
303 | ######## |
304 | # pp_hot.c [pp_aelem] |
305 | { |
306 | use warnings 'misc'; |
307 | print $x[\1]; |
308 | } |
309 | { |
310 | no warnings 'misc'; |
311 | print $x[\1]; |
312 | } |
313 | |
314 | EXPECT |
315 | OPTION regex |
316 | Use of reference ".*" as array index at - line 4. |
1f1cc344 |
317 | ######## |
318 | # pp_hot.c [pp_aelem] |
319 | package Foo;use overload q("") => sub {};package main;$a = bless {}, "Foo"; |
320 | $b = {}; |
321 | { |
322 | use warnings 'misc'; |
323 | print $x[$a]; |
324 | print $x[$b]; |
325 | } |
326 | { |
327 | no warnings 'misc'; |
328 | print $x[$a]; |
329 | print $x[$b]; |
330 | } |
331 | |
332 | EXPECT |
333 | OPTION regex |
334 | Use of reference ".*" as array index at - line 7. |