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