This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Explicitely point to $. when it causes an uninitialized warning for ranges in scalar...
[perl5.git] / t / lib / warnings / 9uninit
CommitLineData
29489e7c
DM
1DAPM 4/2004.
2
3Test the appearance of variable names in "Use of uninitialized value"
4warnings.
5
6The following ops aren't tested, mainly because they do IO or non-portable
7stuff:
8
9 send recv bind conect listen accept shutdown chdir chown chroot unlink
10 chmod utime rename link symlink readlink mkdir rmdir opendir seekdir
11 system exec kill getpgrp alarm sleep dofile require gethostbyname
12 gethostbyaddr getnetbyname getnetbyaddr getprotobyname getprotobynumber
13 getservbyname getservbyport sethostent setnetent setprotoent setservent
14 getpwnam getpwuid getgrnam getgrgid waitpid setpgrp setpriority
15 getpriority syscall dbmopen ioctl fcntl truncate getsockopt setsockopt
16 semctl semop semget msgget msgctl msgsnd msgrcv shmget shmctl shmread
17 shmwrite
18
19 ---------------------------------------------------
20
21
22__END__
23use warnings 'uninitialized';
24my ($m1, $m2, $v);
25
26$v = $m1 + 10;
27$v = 22 + $m2;
28$v = $m1 + $m2;
29EXPECT
30Use of uninitialized value $m1 in addition (+) at - line 4.
31Use of uninitialized value $m2 in addition (+) at - line 5.
32Use of uninitialized value $m2 in addition (+) at - line 6.
33Use of uninitialized value $m1 in addition (+) at - line 6.
34########
35use warnings 'uninitialized';
36my ($m1, $v);
37our ($g1, $g2);
38
39$v = $g1 + 21;
40$v = 31 + $g2;
41$v = $g1 + $g2;
42$v = $m1 + $g2;
43EXPECT
44Use of uninitialized value $g1 in addition (+) at - line 5.
45Use of uninitialized value $g2 in addition (+) at - line 6.
46Use of uninitialized value $g2 in addition (+) at - line 7.
47Use of uninitialized value $g1 in addition (+) at - line 7.
48Use of uninitialized value $g2 in addition (+) at - line 8.
49Use of uninitialized value $m1 in addition (+) at - line 8.
50########
51use warnings 'uninitialized';
52my ($m1, @ma, $v);
53
54$v = $ma[5] + 45;
55$v = 56 + $ma[6];
56$v = $ma[7] + $m1;
57$v = $ma[8] + $ma[9];
58$v = $ma[-1] + $ma[-2];
59EXPECT
60Use of uninitialized value $ma[5] in addition (+) at - line 4.
61Use of uninitialized value $ma[6] in addition (+) at - line 5.
62Use of uninitialized value $m1 in addition (+) at - line 6.
63Use of uninitialized value in addition (+) at - line 6.
64Use of uninitialized value in addition (+) at - line 7.
65Use of uninitialized value in addition (+) at - line 7.
66Use of uninitialized value in addition (+) at - line 8.
67Use of uninitialized value in addition (+) at - line 8.
68########
69use warnings 'uninitialized';
70my ($v);
71my @mau = (undef) x 258;
72my %mhu = ('foo', undef, 'bar', undef);
73
74$v = $mau[5] + 23;
75$v = $mau[-5] + 45;
76$v = 56 + $mau[6];
77$v = 78 + $mau[-6];
78$v = $mau[7] + $mau[8];
79$v = $mau[256] + $mau[257];
80$v = $mau[-1] + $mau[-2];
81$v = $mhu{foo} + $mhu{bar};
82EXPECT
83Use of uninitialized value $mau[5] in addition (+) at - line 6.
84Use of uninitialized value $mau[-5] in addition (+) at - line 7.
85Use of uninitialized value $mau[6] in addition (+) at - line 8.
86Use of uninitialized value $mau[-6] in addition (+) at - line 9.
87Use of uninitialized value $mau[8] in addition (+) at - line 10.
88Use of uninitialized value $mau[7] in addition (+) at - line 10.
89Use of uninitialized value $mau[257] in addition (+) at - line 11.
90Use of uninitialized value $mau[256] in addition (+) at - line 11.
91Use of uninitialized value $mau[-2] in addition (+) at - line 12.
92Use of uninitialized value $mau[-1] in addition (+) at - line 12.
93Use of uninitialized value $mhu{"bar"} in addition (+) at - line 13.
94Use of uninitialized value $mhu{"foo"} in addition (+) at - line 13.
95########
96use warnings 'uninitialized';
97my ($v);
98our (@ga);
99
100$v = $ga[8] + 21;
101$v = $ga[-8] + 46;
102$v = 57 + $ga[9];
103$v = 58 + $ga[-9];
104$v = $ga[10] + $ga[11];
105$v = $ga[-10] + $ga[-11];
106EXPECT
107Use of uninitialized value $ga[8] in addition (+) at - line 5.
108Use of uninitialized value $ga[-8] in addition (+) at - line 6.
109Use of uninitialized value $ga[9] in addition (+) at - line 7.
110Use of uninitialized value $ga[-9] in addition (+) at - line 8.
111Use of uninitialized value in addition (+) at - line 9.
112Use of uninitialized value in addition (+) at - line 9.
113Use of uninitialized value in addition (+) at - line 10.
114Use of uninitialized value in addition (+) at - line 10.
115########
116use warnings 'uninitialized';
117my ($v);
118our @gau = (undef) x 258;
119our %ghu = ('foo', undef, 'bar', undef);
120
121$v = $gau[8] + 46;
122$v = $gau[-8] + 47;
123$v = 57 + $gau[9];
124$v = 57 + $gau[-9];
125$v = $gau[10] + $gau[11];
126$v = $gau[256] + $gau[257];
127$v = $gau[-1] + $gau[-2];
128$v = $ghu{foo} + $ghu{bar};
129EXPECT
130Use of uninitialized value $gau[8] in addition (+) at - line 6.
131Use of uninitialized value $gau[-8] in addition (+) at - line 7.
132Use of uninitialized value $gau[9] in addition (+) at - line 8.
133Use of uninitialized value $gau[-9] in addition (+) at - line 9.
134Use of uninitialized value $gau[11] in addition (+) at - line 10.
135Use of uninitialized value $gau[10] in addition (+) at - line 10.
136Use of uninitialized value $gau[257] in addition (+) at - line 11.
137Use of uninitialized value $gau[256] in addition (+) at - line 11.
138Use of uninitialized value $gau[-2] in addition (+) at - line 12.
139Use of uninitialized value $gau[-1] in addition (+) at - line 12.
140Use of uninitialized value $ghu{"bar"} in addition (+) at - line 13.
141Use of uninitialized value $ghu{"foo"} in addition (+) at - line 13.
142########
143use warnings 'uninitialized';
144my ($v);
145our @gau = (undef) x 258;
146our %ghu = ('foo', undef, 'bar', undef);
147my @mau = (undef) x 258;
148my %mhu = ('foo', undef, 'bar', undef);
149
150my $i1 = 10;
151my $i2 = 20;
152my $i3 = 2000;
153my $k1 = 'foo';
154my $k2 = 'bar';
155my $k3 = 'baz';
156$v = $mau[$i1] + $mau[$i2];
157$v = $gau[$i1] + $gau[$i2];
158$v = $gau[$i1] + $gau[$i3];
159$v = $mhu{$k1} + $mhu{$k2};
160$v = $ghu{$k1} + $ghu{$k2};
161$v = $ghu{$k1} + $ghu{$k3};
162EXPECT
163Use of uninitialized value $mau[20] in addition (+) at - line 14.
164Use of uninitialized value $mau[10] in addition (+) at - line 14.
165Use of uninitialized value $gau[20] in addition (+) at - line 15.
166Use of uninitialized value $gau[10] in addition (+) at - line 15.
167Use of uninitialized value in addition (+) at - line 16.
168Use of uninitialized value $gau[10] in addition (+) at - line 16.
169Use of uninitialized value $mhu{"bar"} in addition (+) at - line 17.
170Use of uninitialized value $mhu{"foo"} in addition (+) at - line 17.
171Use of uninitialized value $ghu{"bar"} in addition (+) at - line 18.
172Use of uninitialized value $ghu{"foo"} in addition (+) at - line 18.
173Use of uninitialized value in addition (+) at - line 19.
174Use of uninitialized value $ghu{"foo"} in addition (+) at - line 19.
175########
176use warnings 'uninitialized';
177my ($m1, $m2, @ma, %mh, $v);
178our ($g1, $g2, @ga, %gh);
179
180$v = $ma[$m1];
181$v = $ma[$g1];
182$v = $ga[$m2];
183$v = $ga[$g2];
184
185$v = $mh{$m1};
186$v = $mh{$g1};
187$v = $gh{$m2};
188$v = $gh{$g2};
189
190$v = $m1+($m2-$g1);
191$v = $ma[$ga[3]];
192$v = $ga[$ma[4]];
193EXPECT
194Use of uninitialized value $m1 in array element at - line 5.
195Use of uninitialized value $g1 in array element at - line 6.
196Use of uninitialized value $m2 in array element at - line 7.
197Use of uninitialized value $g2 in array element at - line 8.
198Use of uninitialized value $m1 in hash element at - line 10.
199Use of uninitialized value $g1 in hash element at - line 11.
200Use of uninitialized value $m2 in hash element at - line 12.
201Use of uninitialized value $g2 in hash element at - line 13.
202Use of uninitialized value $g1 in subtraction (-) at - line 15.
203Use of uninitialized value $m2 in subtraction (-) at - line 15.
204Use of uninitialized value $m1 in addition (+) at - line 15.
205Use of uninitialized value $ga[3] in array element at - line 16.
206Use of uninitialized value $ma[4] in array element at - line 17.
207########
208use warnings 'uninitialized';
209my (@ma, %mh, $v);
210our (@ga, %gh);
211
212$v = sin $ga[1000];
213$v = sin $ma[1000];
214$v = sin $gh{foo};
215$v = sin $mh{bar};
216
217$v = sin $ga[$$];
218$v = sin $ma[$$];
219$v = sin $gh{$$};
220$v = sin $mh{$$};
221EXPECT
222Use of uninitialized value $ga[1000] in sin at - line 5.
223Use of uninitialized value $ma[1000] in sin at - line 6.
224Use of uninitialized value $gh{"foo"} in sin at - line 7.
225Use of uninitialized value $mh{"bar"} in sin at - line 8.
226Use of uninitialized value within @ga in sin at - line 10.
227Use of uninitialized value within @ma in sin at - line 11.
228Use of uninitialized value within %gh in sin at - line 12.
229Use of uninitialized value within %mh in sin at - line 13.
230########
231use warnings 'uninitialized';
232my (@mat, %mht, $v);
233sub X::TIEARRAY { bless [], 'X' }
234sub X::TIEHASH { bless [], 'X' }
235sub X::FETCH { undef }
236tie @mat, 'X';
237tie %mht, 'X';
238my $key1 = 'akey';
239my $key2 = 'bkey';
240my $index1 = 33;
241my $index2 = 55;
242
243$v = sin $mat[0];
244$v = $mat[0] + $mat[1];
245$v = sin $mat[1000];
246$v = $mat[1000] + $mat[1001];
247
248$v = sin $mat[$index1];
249$v = $mat[$index1] + $mat[$index2];
250
251$v = sin $mht{foo};
252$v = $mht{foo} + $mht{bar};
253
254$v = sin $mht{$key1};
255$v = $mht{$key1} + $mht{$key2};
256
257$v = $1+1;
258EXPECT
259Use of uninitialized value $mat[0] in sin at - line 13.
260Use of uninitialized value in addition (+) at - line 14.
261Use of uninitialized value in addition (+) at - line 14.
262Use of uninitialized value $mat[1000] in sin at - line 15.
263Use of uninitialized value in addition (+) at - line 16.
264Use of uninitialized value in addition (+) at - line 16.
265Use of uninitialized value within @mat in sin at - line 18.
266Use of uninitialized value in addition (+) at - line 19.
267Use of uninitialized value in addition (+) at - line 19.
268Use of uninitialized value $mht{"foo"} in sin at - line 21.
269Use of uninitialized value in addition (+) at - line 22.
270Use of uninitialized value in addition (+) at - line 22.
271Use of uninitialized value within %mht in sin at - line 24.
272Use of uninitialized value in addition (+) at - line 25.
273Use of uninitialized value in addition (+) at - line 25.
274Use of uninitialized value $1 in addition (+) at - line 27.
275########
276use warnings 'uninitialized';
277my ($m1);
278our ($g1, @ga);
279
280print $ga[1000];
281print STDERR $ga[1000];
282print STDERR $m1, $g1, $ga[1],$m2;
283print STDERR "", $ga[1],"";
284EXPECT
fa8d1836
DM
285Use of uninitialized value in print at - line 5.
286Use of uninitialized value in print at - line 6.
29489e7c
DM
287Use of uninitialized value $m1 in print at - line 7.
288Use of uninitialized value $g1 in print at - line 7.
289Use of uninitialized value in print at - line 7.
290Use of uninitialized value $m2 in print at - line 7.
fa8d1836 291Use of uninitialized value in print at - line 8.
29489e7c
DM
292########
293use warnings 'uninitialized';
294my ($m1);
295our ($g1);
296
297close $m1; # exercises rv2gv
298close $g1; # exercises rv2gv
299EXPECT
300Use of uninitialized value $m1 in ref-to-glob cast at - line 5.
301Use of uninitialized value $g1 in ref-to-glob cast at - line 6.
302########
303use warnings 'uninitialized';
304my ($m1, $m2, $v);
305our ($g1, $g2);
306
307$v = $$m1;
308$v = $$g1;
309
310$v = @$m1;
311$v = @$g1;
312$v = %$m2;
313$v = %$g2;
e21bd382
DM
314
315$v = ${"foo.bar"}+1;
316$v = ${"foo$m1"}+1;
317$v = ${"foo$g1"}+1;
29489e7c
DM
318EXPECT
319Use of uninitialized value $m1 in scalar dereference at - line 5.
320Use of uninitialized value $g1 in scalar dereference at - line 6.
321Use of uninitialized value $m1 in array dereference at - line 8.
322Use of uninitialized value $g1 in array dereference at - line 9.
323Use of uninitialized value $m2 in hash dereference at - line 10.
324Use of uninitialized value $g2 in hash dereference at - line 11.
e21bd382
DM
325Use of uninitialized value in addition (+) at - line 13.
326Use of uninitialized value $m1 in concatenation (.) or string at - line 14.
327Use of uninitialized value in addition (+) at - line 14.
328Use of uninitialized value $g1 in concatenation (.) or string at - line 15.
329Use of uninitialized value in addition (+) at - line 15.
29489e7c
DM
330########
331use warnings 'uninitialized';
332my ($m1, $v);
333our ($g1);
334
335$v = $m1 | $m2;
336$v = $m1 & $m2;
337$v = $m1 ^ $m2;
338$v = ~$m1;
339
340$v = $g1 | $g2;
341$v = $g1 & $g2;
342$v = $g1 ^ $g2;
343$v = ~$g1;
344EXPECT
345Use of uninitialized value $m1 in bitwise or (|) at - line 5.
346Use of uninitialized value $m2 in bitwise or (|) at - line 5.
347Use of uninitialized value $m1 in bitwise and (&) at - line 6.
348Use of uninitialized value $m2 in bitwise and (&) at - line 6.
349Use of uninitialized value $m1 in bitwise xor (^) at - line 7.
350Use of uninitialized value $m2 in bitwise xor (^) at - line 7.
351Use of uninitialized value $m1 in 1's complement (~) at - line 8.
352Use of uninitialized value $g1 in bitwise or (|) at - line 10.
353Use of uninitialized value $g2 in bitwise or (|) at - line 10.
354Use of uninitialized value $g1 in bitwise and (&) at - line 11.
355Use of uninitialized value $g2 in bitwise and (&) at - line 11.
356Use of uninitialized value $g1 in bitwise xor (^) at - line 12.
357Use of uninitialized value $g2 in bitwise xor (^) at - line 12.
358Use of uninitialized value $g1 in 1's complement (~) at - line 13.
359########
360use warnings 'uninitialized';
361my ($v);
362
363my $tmp1; $v = $tmp1++; # (doesn't warn)
364our $tmp2; $v = $tmp2++; # (doesn't warn)
365my $tmp3; $v = ++$tmp1; # (doesn't warn)
366our $tmp4; $v = ++$tmp2; # (doesn't warn)
367
368my $tmp5; $v = $tmp5--; # (doesn't warn)
369our $tmp6; $v = $tmp6--; # (doesn't warn)
370my $tmp7; $v = --$tmp7; # (doesn't warn)
371our $tmp8; $v = --$tmp8; # (doesn't warn)
372EXPECT
373########
374use warnings 'uninitialized';
375
376my $s1; chomp $s1;
377my $s2; chop $s2;
378my ($s3,$s4); chomp ($s3,$s4);
379my ($s5,$s6); chop ($s5,$s6);
380EXPECT
381Use of uninitialized value $s1 in scalar chomp at - line 3.
382Use of uninitialized value $s2 in scalar chop at - line 4.
383Use of uninitialized value $s4 in chomp at - line 5.
384Use of uninitialized value $s3 in chomp at - line 5.
385Use of uninitialized value $s5 in chop at - line 6.
386Use of uninitialized value $s6 in chop at - line 6.
387########
388use warnings 'uninitialized';
389my ($m1);
390
391local $/ =\$m1;
392my $x = "abc";
393chomp $x; chop $x;
394my $y;
395chomp ($x, $y); chop ($x, $y);
396EXPECT
397Use of uninitialized value ${$/} in scalar chomp at - line 6.
398Use of uninitialized value ${$/} in chomp at - line 8.
399Use of uninitialized value $y in chomp at - line 8.
400Use of uninitialized value ${$/} in chomp at - line 8.
401Use of uninitialized value $y in chop at - line 8.
402########
403use warnings 'uninitialized';
404my ($m1, @ma, %mh);
405our ($g1);
406
407delete $ma[$m1];
408delete @ma[$m1, $g1];
409delete $mh{$m1};
410delete @mh{$m1, $g1};
411EXPECT
412Use of uninitialized value $m1 in delete at - line 5.
413Use of uninitialized value $m1 in delete at - line 6.
414Use of uninitialized value $g1 in delete at - line 6.
415Use of uninitialized value $m1 in delete at - line 7.
416Use of uninitialized value $m1 in delete at - line 8.
417Use of uninitialized value $g1 in delete at - line 8.
418########
419use warnings 'uninitialized';
420my ($m1, @ma, %mh);
421our ($g1);
422
423my @a = @ma[$m1, $g1];
424@a = (4,5)[$m1, $g1];
425@a = @mh{$m1, $g1};
426EXPECT
427Use of uninitialized value $m1 in array slice at - line 5.
428Use of uninitialized value $g1 in array slice at - line 5.
429Use of uninitialized value $m1 in list slice at - line 6.
430Use of uninitialized value $g1 in list slice at - line 6.
431Use of uninitialized value $m1 in hash slice at - line 7.
432Use of uninitialized value $g1 in hash slice at - line 7.
433########
434use warnings 'uninitialized';
435my ($m1, @ma, %mh, $v);
436our ($g1, @ga, %gh);
437
438$v = exists $ma[$m1];
439$v = exists $ga[$g1];
440$v = exists $mh{$m1};
441$v = exists $gh{$g1};
442EXPECT
443Use of uninitialized value $m1 in exists at - line 5.
444Use of uninitialized value $g1 in exists at - line 6.
445Use of uninitialized value $m1 in exists at - line 7.
446Use of uninitialized value $g1 in exists at - line 8.
447########
448use warnings 'uninitialized';
4f187fc9
VP
449my ($m1, $m2);
450my ($v, @a);
451
452local $.;
453
454@ma = (1 .. 2);
455@ma = ($m1 .. 2);
456@ma = (1 .. $m2);
457@ma = ($m1 .. $m2);
458
459$v = (1 .. 2);
460$v = ($m1 .. 2);
461$v = (1 .. $m2);
462$v = ($m1 .. $m2);
463EXPECT
464Use of uninitialized value $m1 in range (or flop) at - line 8.
465Use of uninitialized value $m2 in range (or flop) at - line 9.
466Use of uninitialized value in range (or flop) at - line 10.
467Use of uninitialized value in range (or flop) at - line 10.
468Use of uninitialized value $. in range (or flip) at - line 12.
469Use of uninitialized value $. in range (or flip) at - line 14.
470########
471use warnings 'uninitialized';
29489e7c
DM
472my ($m1, $v);
473our ($g1);
474
475my ($x1,$x2);
476$v = $x1 << $m1;
477$v = $x2 << $g1;
478EXPECT
479Use of uninitialized value $m1 in left bitshift (<<) at - line 6.
480Use of uninitialized value $x1 in left bitshift (<<) at - line 6.
481Use of uninitialized value $g1 in left bitshift (<<) at - line 7.
482Use of uninitialized value $x2 in left bitshift (<<) at - line 7.
483########
484use warnings 'uninitialized';
485my ($m1, $m2, $v);
486our ($g1, $g2);
487
488use integer;
489$v = $m1 + $g1;
490$v = $m1 - $g1;
491$v = $m1 * $g1;
492eval {$v = $m1 / $g1};
493$v = $m2 / 2;
494eval {$v = $m1 % $g1};
495$v = $m2 % 2;
496$v = $m1 < $g1;
497$v = $m1 > $g1;
498$v = $m1 <= $g1;
499$v = $m1 >= $g1;
500$v = $m1 == $g1;
501$v = $m1 != $g1;
502$v = $m1 <=> $g1;
503$v = -$m1;
504EXPECT
505Use of uninitialized value $g1 in integer addition (+) at - line 6.
506Use of uninitialized value $m1 in integer addition (+) at - line 6.
507Use of uninitialized value $g1 in integer subtraction (-) at - line 7.
508Use of uninitialized value $m1 in integer subtraction (-) at - line 7.
509Use of uninitialized value $g1 in integer multiplication (*) at - line 8.
510Use of uninitialized value $m1 in integer multiplication (*) at - line 8.
511Use of uninitialized value $g1 in integer division (/) at - line 9.
512Use of uninitialized value $m2 in integer division (/) at - line 10.
513Use of uninitialized value $g1 in integer modulus (%) at - line 11.
514Use of uninitialized value $m1 in integer modulus (%) at - line 11.
515Use of uninitialized value $m2 in integer modulus (%) at - line 12.
516Use of uninitialized value $g1 in integer lt (<) at - line 13.
517Use of uninitialized value $m1 in integer lt (<) at - line 13.
518Use of uninitialized value $g1 in integer gt (>) at - line 14.
519Use of uninitialized value $m1 in integer gt (>) at - line 14.
520Use of uninitialized value $g1 in integer le (<=) at - line 15.
521Use of uninitialized value $m1 in integer le (<=) at - line 15.
522Use of uninitialized value $g1 in integer ge (>=) at - line 16.
523Use of uninitialized value $m1 in integer ge (>=) at - line 16.
524Use of uninitialized value $g1 in integer eq (==) at - line 17.
525Use of uninitialized value $m1 in integer eq (==) at - line 17.
526Use of uninitialized value $g1 in integer ne (!=) at - line 18.
527Use of uninitialized value $m1 in integer ne (!=) at - line 18.
528Use of uninitialized value $g1 in integer comparison (<=>) at - line 19.
529Use of uninitialized value $m1 in integer comparison (<=>) at - line 19.
530Use of uninitialized value $m1 in integer negation (-) at - line 20.
531########
532use warnings 'uninitialized';
533my ($m1, $m2, $v);
534our ($g1, $g2);
535
536$v = int($g1);
537$v = abs($g2);
538EXPECT
539Use of uninitialized value $g1 in int at - line 5.
29489e7c
DM
540Use of uninitialized value $g2 in abs at - line 6.
541########
542use warnings 'uninitialized';
543my ($m1, $m2, $v);
544our ($g1);
545
546$v = pack $m1;
547$v = pack "i*", $m2, $g1, $g2;
548my @unpack = unpack $m1, $m2;
549EXPECT
550Use of uninitialized value $m1 in pack at - line 5.
551Use of uninitialized value $m2 in pack at - line 6.
552Use of uninitialized value $g1 in pack at - line 6.
553Use of uninitialized value $g2 in pack at - line 6.
554Use of uninitialized value $m1 in unpack at - line 7.
555Use of uninitialized value $m2 in unpack at - line 7.
556########
557use warnings 'uninitialized';
558my ($m1);
559our ($g1);
560
561my @sort;
562@sort = sort $m1, $g1;
563@sort = sort {$a <=> $b} $m1, $g1;
564sub sortf {$a-1 <=> $b-1};
565@sort = sort &sortf, $m1, $g1;
566EXPECT
567Use of uninitialized value $m1 in sort at - line 6.
568Use of uninitialized value $g1 in sort at - line 6.
569Use of uninitialized value $m1 in sort at - line 6.
570Use of uninitialized value $g1 in sort at - line 6.
571Use of uninitialized value $m1 in sort at - line 7.
572Use of uninitialized value $g1 in sort at - line 7.
573Use of uninitialized value $m1 in sort at - line 7.
574Use of uninitialized value $g1 in sort at - line 7.
575Use of uninitialized value $a in subtraction (-) at - line 8.
576Use of uninitialized value $b in subtraction (-) at - line 8.
577Use of uninitialized value $m1 in sort at - line 9.
578Use of uninitialized value $g1 in sort at - line 9.
579Use of uninitialized value $m1 in sort at - line 9.
580Use of uninitialized value $m1 in sort at - line 9.
581Use of uninitialized value $g1 in sort at - line 9.
582Use of uninitialized value $g1 in sort at - line 9.
583########
584use warnings 'uninitialized';
585my ($m1, $m2, $v);
586our ($g1);
587
588eval { $v = $m1 / $g1 };
589$v = $m2 / 2;
590eval { $v = $m1 % $g1 };
591$v = $m2 % 2;
592$v = $m1 == $g1;
593$v = $m1 >= $g1;
594$v = $m1 > $g1;
595$v = $m1 <= $g1;
596$v = $m1 < $g1;
597$v = $m1 * $g1;
598$v = $m1 <=>$g1;
599$v = $m1 != $g1;
600$v = $m1 -$g1;
601$v = $m1 ** $g1;
602$v = $m1 + $g1;
603$v = $m1 - $g1;
604EXPECT
605Use of uninitialized value $g1 in division (/) at - line 5.
606Use of uninitialized value $m1 in division (/) at - line 5.
607Use of uninitialized value $m2 in division (/) at - line 6.
608Use of uninitialized value $g1 in modulus (%) at - line 7.
609Use of uninitialized value $m1 in modulus (%) at - line 7.
610Use of uninitialized value $m2 in modulus (%) at - line 8.
611Use of uninitialized value $g1 in numeric eq (==) at - line 9.
612Use of uninitialized value $m1 in numeric eq (==) at - line 9.
613Use of uninitialized value $g1 in numeric ge (>=) at - line 10.
614Use of uninitialized value $m1 in numeric ge (>=) at - line 10.
615Use of uninitialized value $g1 in numeric gt (>) at - line 11.
616Use of uninitialized value $m1 in numeric gt (>) at - line 11.
617Use of uninitialized value $g1 in numeric le (<=) at - line 12.
618Use of uninitialized value $m1 in numeric le (<=) at - line 12.
619Use of uninitialized value $g1 in numeric lt (<) at - line 13.
620Use of uninitialized value $m1 in numeric lt (<) at - line 13.
621Use of uninitialized value $g1 in multiplication (*) at - line 14.
622Use of uninitialized value $m1 in multiplication (*) at - line 14.
623Use of uninitialized value $g1 in numeric comparison (<=>) at - line 15.
624Use of uninitialized value $m1 in numeric comparison (<=>) at - line 15.
625Use of uninitialized value $g1 in numeric ne (!=) at - line 16.
626Use of uninitialized value $m1 in numeric ne (!=) at - line 16.
627Use of uninitialized value $g1 in subtraction (-) at - line 17.
628Use of uninitialized value $m1 in subtraction (-) at - line 17.
629Use of uninitialized value $g1 in exponentiation (**) at - line 18.
630Use of uninitialized value $m1 in exponentiation (**) at - line 18.
631Use of uninitialized value $g1 in addition (+) at - line 19.
632Use of uninitialized value $m1 in addition (+) at - line 19.
633Use of uninitialized value $g1 in subtraction (-) at - line 20.
634Use of uninitialized value $m1 in subtraction (-) at - line 20.
635########
636use warnings 'uninitialized';
637my ($m1, $v);
638our ($g1);
639
640$v = *global1{$m1};
641$v = prototype $g1;
642$v = bless [], $g1;
643$v = `$m1`;
644
645$v = $m1 . $g1;
646EXPECT
647Use of uninitialized value $m1 in glob elem at - line 5.
648Use of uninitialized value $g1 in subroutine prototype at - line 6.
649Use of uninitialized value $g1 in bless at - line 7.
650Use of uninitialized value $m1 in quoted execution (``, qx) at - line 8.
29489e7c 651Use of uninitialized value $m1 in concatenation (.) or string at - line 10.
c75ab21a 652Use of uninitialized value $g1 in concatenation (.) or string at - line 10.
29489e7c
DM
653########
654use warnings 'uninitialized';
655my ($m1);
656our ($g1, $g2);
657
658/y/;
659/$m1/;
660/$g1/;
661
662s/y/z/; undef $_;
663s/$m1/z/; undef $_;
664s//$g1/; undef $_;
665s/$m1/$g1/; undef $_;
666tr/x/y/; undef $_;
667
668my $_;
669/y/;
670/$m1/;
671/$g1/;
672s/y/z/; undef $_;
673s/$m1/z/; undef $_;
674s//$g1/; undef $_;
675s/$m1/$g1/; undef $_;
676tr/x/y/; undef $_;
677
678$g2 =~ /y/;
679$g2 =~ /$m1/;
680$g2 =~ /$g1/;
681$g2 =~ s/y/z/; undef $g2;
682$g2 =~ s/$m1/z/; undef $g2;
683$g2 =~ s//$g1/; undef $g2;
684$g2 =~ s/$m1/$g1/; undef $g2;
685$g2 =~ tr/x/y/; undef $g2; # XXX can't extract var name yet
686
687my $foo = "abc";
688$foo =~ /$m1/;
689$foo =~ /$g1/;
690$foo =~ s/y/z/;
691$foo =~ s/$m1/z/;
692$foo =~ s//$g1/;
693$foo =~ s/$m1/$g1/;
694$foo =~ s/./$m1/e;
50edf520
DM
695undef $g1;
696$m1 = '$g1';
697$foo =~ s//$m1/ee;
29489e7c
DM
698EXPECT
699Use of uninitialized value $_ in pattern match (m//) at - line 5.
700Use of uninitialized value $m1 in regexp compilation at - line 6.
701Use of uninitialized value $_ in pattern match (m//) at - line 6.
702Use of uninitialized value $g1 in regexp compilation at - line 7.
703Use of uninitialized value $_ in pattern match (m//) at - line 7.
704Use of uninitialized value $_ in substitution (s///) at - line 9.
705Use of uninitialized value $m1 in regexp compilation at - line 10.
706Use of uninitialized value $_ in substitution (s///) at - line 10.
707Use of uninitialized value $_ in substitution (s///) at - line 10.
708Use of uninitialized value $_ in substitution (s///) at - line 11.
709Use of uninitialized value $g1 in substitution (s///) at - line 11.
710Use of uninitialized value $_ in substitution (s///) at - line 11.
711Use of uninitialized value $g1 in substitution (s///) at - line 11.
712Use of uninitialized value $m1 in regexp compilation at - line 12.
713Use of uninitialized value $_ in substitution (s///) at - line 12.
714Use of uninitialized value $_ in substitution (s///) at - line 12.
715Use of uninitialized value $g1 in substitution iterator at - line 12.
716Use of uninitialized value $_ in transliteration (tr///) at - line 13.
717Use of uninitialized value $_ in pattern match (m//) at - line 16.
718Use of uninitialized value $m1 in regexp compilation at - line 17.
719Use of uninitialized value $_ in pattern match (m//) at - line 17.
720Use of uninitialized value $g1 in regexp compilation at - line 18.
721Use of uninitialized value $_ in pattern match (m//) at - line 18.
722Use of uninitialized value $_ in substitution (s///) at - line 19.
723Use of uninitialized value $m1 in regexp compilation at - line 20.
724Use of uninitialized value $_ in substitution (s///) at - line 20.
725Use of uninitialized value $_ in substitution (s///) at - line 20.
726Use of uninitialized value $_ in substitution (s///) at - line 21.
727Use of uninitialized value $g1 in substitution (s///) at - line 21.
728Use of uninitialized value $_ in substitution (s///) at - line 21.
729Use of uninitialized value $g1 in substitution (s///) at - line 21.
730Use of uninitialized value $m1 in regexp compilation at - line 22.
731Use of uninitialized value $_ in substitution (s///) at - line 22.
732Use of uninitialized value $_ in substitution (s///) at - line 22.
733Use of uninitialized value $g1 in substitution iterator at - line 22.
734Use of uninitialized value $_ in transliteration (tr///) at - line 23.
735Use of uninitialized value $g2 in pattern match (m//) at - line 25.
736Use of uninitialized value $m1 in regexp compilation at - line 26.
737Use of uninitialized value $g2 in pattern match (m//) at - line 26.
738Use of uninitialized value $g1 in regexp compilation at - line 27.
739Use of uninitialized value $g2 in pattern match (m//) at - line 27.
740Use of uninitialized value $g2 in substitution (s///) at - line 28.
741Use of uninitialized value $m1 in regexp compilation at - line 29.
742Use of uninitialized value $g2 in substitution (s///) at - line 29.
743Use of uninitialized value $g2 in substitution (s///) at - line 29.
744Use of uninitialized value $g2 in substitution (s///) at - line 30.
745Use of uninitialized value $g1 in substitution (s///) at - line 30.
746Use of uninitialized value $g2 in substitution (s///) at - line 30.
747Use of uninitialized value $g1 in substitution (s///) at - line 30.
748Use of uninitialized value $m1 in regexp compilation at - line 31.
749Use of uninitialized value $g2 in substitution (s///) at - line 31.
750Use of uninitialized value $g2 in substitution (s///) at - line 31.
751Use of uninitialized value $g1 in substitution iterator at - line 31.
752Use of uninitialized value in transliteration (tr///) at - line 32.
753Use of uninitialized value $m1 in regexp compilation at - line 35.
754Use of uninitialized value $g1 in regexp compilation at - line 36.
755Use of uninitialized value $m1 in regexp compilation at - line 38.
756Use of uninitialized value $g1 in substitution (s///) at - line 39.
757Use of uninitialized value $m1 in regexp compilation at - line 40.
758Use of uninitialized value $g1 in substitution iterator at - line 40.
759Use of uninitialized value $m1 in substitution iterator at - line 41.
50edf520 760Use of uninitialized value in substitution iterator at - line 44.
29489e7c
DM
761########
762use warnings 'uninitialized';
763my ($m1);
764
765{ my $foo = "abc"; (substr($foo,0,0)) = ($m1) }
766EXPECT
767Use of uninitialized value $m1 in list assignment at - line 4.
768########
769use warnings 'uninitialized';
770our ($g1);
771
772study;
773study $g1;
774EXPECT
775Use of uninitialized value $_ in study at - line 4.
776Use of uninitialized value $g1 in study at - line 5.
777########
778use warnings 'uninitialized';
779my ($m1);
780
781pos()=0;
782pos($m1)=0;
783EXPECT
784Use of uninitialized value $_ in scalar assignment at - line 4.
785Use of uninitialized value $m1 in scalar assignment at - line 5.
786########
787use warnings 'uninitialized';
788my ($m1);
cc4b8646
DM
789our ($g1);
790
791$v = pos($m1) + 1;
792$v = pos($g1) + 1;
793$m1 = 0;
794$g1 = "";
795$v = pos($m1) + 1;
796$v = pos($g1) + 1;
797EXPECT
798Use of uninitialized value in addition (+) at - line 5.
799Use of uninitialized value in addition (+) at - line 6.
800Use of uninitialized value in addition (+) at - line 9.
801Use of uninitialized value in addition (+) at - line 10.
802########
803use warnings 'uninitialized';
804my ($m1);
29489e7c
DM
805
806{ my $x = "a" x $m1 } # NB LHS of repeat does not warn
807{ my @x = ("a") x $m1 }
808EXPECT
809Use of uninitialized value $m1 in repeat (x) at - line 4.
810Use of uninitialized value $m1 in repeat (x) at - line 5.
811########
812use warnings 'uninitialized';
813my ($m1, $v);
814our ($g1);
815
816$v = "$m1";
817
818$v = $m1 lt $g1;
819$v = $m1 le $g1;
820$v = $m1 gt $g1;
821$v = $m1 ge $g1;
822$v = $m1 eq $g1;
823$v = $m1 ne $g1;
824$v = $m1 cmp $g1;
825EXPECT
826Use of uninitialized value $m1 in string at - line 5.
827Use of uninitialized value $m1 in string lt at - line 7.
828Use of uninitialized value $g1 in string lt at - line 7.
829Use of uninitialized value $m1 in string le at - line 8.
830Use of uninitialized value $g1 in string le at - line 8.
831Use of uninitialized value $m1 in string gt at - line 9.
832Use of uninitialized value $g1 in string gt at - line 9.
833Use of uninitialized value $m1 in string ge at - line 10.
834Use of uninitialized value $g1 in string ge at - line 10.
835Use of uninitialized value $m1 in string eq at - line 11.
836Use of uninitialized value $g1 in string eq at - line 11.
837Use of uninitialized value $m1 in string ne at - line 12.
838Use of uninitialized value $g1 in string ne at - line 12.
839Use of uninitialized value $m1 in string comparison (cmp) at - line 13.
840Use of uninitialized value $g1 in string comparison (cmp) at - line 13.
841########
842use warnings 'uninitialized';
843my ($m1, $v);
844our ($g1);
845
846$v = atan2($m1,$g1);
847$v = sin $m1;
848$v = cos $m1;
849$v = rand $m1;
850$v = srand $m1;
851$v = exp $m1;
852$v = eval {log $m1};
853$v = sqrt $m1;
854$v = hex $m1;
855$v = oct $m1;
9f621bb0
NC
856$v = oct;
857$v = length; # does not warn
29489e7c
DM
858EXPECT
859Use of uninitialized value $g1 in atan2 at - line 5.
860Use of uninitialized value $m1 in atan2 at - line 5.
861Use of uninitialized value $m1 in sin at - line 6.
862Use of uninitialized value $m1 in cos at - line 7.
863Use of uninitialized value $m1 in rand at - line 8.
864Use of uninitialized value $m1 in srand at - line 9.
865Use of uninitialized value $m1 in exp at - line 10.
866Use of uninitialized value $m1 in log at - line 11.
867Use of uninitialized value $m1 in sqrt at - line 12.
868Use of uninitialized value $m1 in hex at - line 13.
869Use of uninitialized value $m1 in oct at - line 14.
9f621bb0 870Use of uninitialized value $_ in oct at - line 15.
29489e7c
DM
871########
872use warnings 'uninitialized';
873my ($m1, $v);
874our ($g1);
875
876$v = substr $m1, $g1;
877$v = substr $m1, $g1, $m2;
878$v = substr $m1, $g1, $m2, $g2; undef $m1;
879substr($m1, $g1) = $g2; undef $m1; # NB global2
880substr($m1, $g1, $m2) = $g2; undef $m1; # isn't identified
881
882$v = eval {vec ($m1, $g1, $m2)};
883eval {vec ($m1, $g1, $m2) = $g2}; undef $m1; # ditto
884
885$v = index $m1, $m2;
886$v = index $m1, $m2, $g1;
887$v = rindex $m1, $m2;
888$v = rindex $m1, $m2, $g1;
889EXPECT
890Use of uninitialized value $g1 in substr at - line 5.
891Use of uninitialized value $m1 in substr at - line 5.
892Use of uninitialized value $m2 in substr at - line 6.
893Use of uninitialized value $g1 in substr at - line 6.
894Use of uninitialized value $m1 in substr at - line 6.
895Use of uninitialized value $g2 in substr at - line 7.
896Use of uninitialized value $m2 in substr at - line 7.
897Use of uninitialized value $g1 in substr at - line 7.
898Use of uninitialized value $m1 in substr at - line 7.
29489e7c
DM
899Use of uninitialized value $g1 in substr at - line 8.
900Use of uninitialized value $m1 in substr at - line 8.
901Use of uninitialized value in scalar assignment at - line 8.
902Use of uninitialized value $m2 in substr at - line 9.
903Use of uninitialized value $g1 in substr at - line 9.
904Use of uninitialized value $m1 in substr at - line 9.
905Use of uninitialized value in scalar assignment at - line 9.
906Use of uninitialized value $m2 in vec at - line 11.
907Use of uninitialized value $g1 in vec at - line 11.
908Use of uninitialized value $m1 in vec at - line 11.
909Use of uninitialized value $m2 in vec at - line 12.
910Use of uninitialized value $g1 in vec at - line 12.
911Use of uninitialized value $m1 in vec at - line 12.
912Use of uninitialized value $m1 in index at - line 14.
913Use of uninitialized value $m2 in index at - line 14.
914Use of uninitialized value $g1 in index at - line 15.
915Use of uninitialized value $m1 in index at - line 15.
916Use of uninitialized value $m2 in index at - line 15.
29489e7c 917Use of uninitialized value $m1 in rindex at - line 16.
73ee8be2 918Use of uninitialized value $m2 in rindex at - line 16.
29489e7c 919Use of uninitialized value $g1 in rindex at - line 17.
29489e7c 920Use of uninitialized value $m1 in rindex at - line 17.
73ee8be2 921Use of uninitialized value $m2 in rindex at - line 17.
29489e7c
DM
922########
923use warnings 'uninitialized';
924my ($m1, $v);
925our ($g1);
926
927$v = sprintf $m1;
928$v = sprintf '%d%d%d%d', $m1, $m2, $g1, $g2;
094236a2 929my $m3; eval {formline $m3 };
29489e7c
DM
930formline '@<<@<<@<<@<<', $m1, $m2, $g1, $g2;
931EXPECT
932Use of uninitialized value $m1 in sprintf at - line 5.
933Use of uninitialized value $m1 in sprintf at - line 6.
934Use of uninitialized value $m2 in sprintf at - line 6.
935Use of uninitialized value $g1 in sprintf at - line 6.
936Use of uninitialized value $g2 in sprintf at - line 6.
094236a2 937Use of uninitialized value $m3 in formline at - line 7.
29489e7c
DM
938Use of uninitialized value $m1 in formline at - line 8.
939Use of uninitialized value $m2 in formline at - line 8.
940Use of uninitialized value $g1 in formline at - line 8.
941Use of uninitialized value $g2 in formline at - line 8.
942########
943use warnings 'uninitialized';
944my ($m1, $v);
945our ($g1);
946
947$v = crypt $m1, $g1;
948
949$v = ord;
950$v = ord $m1;
951$v = chr;
952$v = chr $m1;
953
29489e7c
DM
954$v = ucfirst;
955$v = ucfirst $m1;
956$v = lcfirst;
957$v = lcfirst $m1;
958$v = uc;
959$v = uc $m1;
960$v = lc;
961$v = lc $m1;
962
963$v = quotemeta;
964$v = quotemeta $m1;
965EXPECT
966Use of uninitialized value $m1 in crypt at - line 5.
967Use of uninitialized value $g1 in crypt at - line 5.
968Use of uninitialized value $_ in ord at - line 7.
969Use of uninitialized value $m1 in ord at - line 8.
970Use of uninitialized value $_ in chr at - line 9.
971Use of uninitialized value $m1 in chr at - line 10.
0a0ffbce
RGS
972Use of uninitialized value $_ in ucfirst at - line 12.
973Use of uninitialized value $m1 in ucfirst at - line 13.
974Use of uninitialized value $_ in lcfirst at - line 14.
975Use of uninitialized value $m1 in lcfirst at - line 15.
976Use of uninitialized value $_ in uc at - line 16.
977Use of uninitialized value $m1 in uc at - line 17.
978Use of uninitialized value $_ in lc at - line 18.
979Use of uninitialized value $m1 in lc at - line 19.
980Use of uninitialized value $_ in quotemeta at - line 21.
981Use of uninitialized value $m1 in quotemeta at - line 22.
29489e7c
DM
982########
983use warnings 'uninitialized';
984my ($m1, $v1, $v2, $v3, $v4);
985our ($g1);
986
987($v1,$v2,$v3,$v4) = split;
988($v1,$v2,$v3,$v4) = split $m1;
989($v1,$v2,$v3,$v4) = split $m1, $m2;
990($v1,$v2,$v3,$v4) = split $m1, $m2, $g1;
991
992$v1 = join $m1;
993$v2 = join $m1, $m2;
994$v3 = join $m1, $m2, $m3;
995EXPECT
996Use of uninitialized value $_ in split at - line 5.
997Use of uninitialized value $m1 in regexp compilation at - line 6.
998Use of uninitialized value $_ in split at - line 6.
999Use of uninitialized value $m1 in regexp compilation at - line 7.
1000Use of uninitialized value $m2 in split at - line 7.
1001Use of uninitialized value $m1 in regexp compilation at - line 8.
1002Use of uninitialized value $g1 in split at - line 8.
1003Use of uninitialized value $m2 in split at - line 8.
1004Use of uninitialized value $m1 in join or string at - line 10.
1005Use of uninitialized value $m1 in join or string at - line 11.
1006Use of uninitialized value $m2 in join or string at - line 11.
1007Use of uninitialized value $m1 in join or string at - line 12.
1008Use of uninitialized value $m2 in join or string at - line 12.
1009Use of uninitialized value $m3 in join or string at - line 12.
1010########
1011use warnings 'uninitialized';
1012my ($m1, $m2, @ma, $v);
1013
1014our @foo1=(1,undef); chomp @foo1;
1015my @foo2=(1,undef); chomp @foo2;
1016our @foo3=(1,undef); chop @foo3;
1017my @foo4=(1,undef); chop @foo4;
1018our @foo5=(1,undef); $v = sprintf "%s%s",@foo5;
1019my @foo6=(1,undef); $v = sprintf "%s%s",@foo6;
1020our %foo7=('foo'=>'bar','baz'=>undef); $v = sprintf "%s%s",%foo7;
1021my %foo8=('foo'=>'bar','baz'=>undef); $v = sprintf "%s%s",%foo8;
1022our @foo9 =(1,undef); $v = sprintf "%s%s%s%s",$m1,@foo9, $ma[2];
1023my @foo10=(1,undef); $v = sprintf "%s%s%s%s",$m2,@foo10,$ma[2];
1024our %foo11=('foo'=>'bar','baz'=>undef); $v = join '', %foo11;
1025my %foo12=('foo'=>'bar','baz'=>undef); $v = join '', %foo12;
1026our %foo13=(1..2000,'foo'=>'bar','baz'=>undef); $v = join '', %foo13;
1027my %foo14=(1..2000,'foo'=>'bar','baz'=>undef); $v = join '', %foo14;
1028EXPECT
1029Use of uninitialized value $foo1[1] in chomp at - line 4.
1030Use of uninitialized value $foo2[1] in chomp at - line 5.
1031Use of uninitialized value $foo3[1] in chop at - line 6.
1032Use of uninitialized value $foo4[1] in chop at - line 7.
1033Use of uninitialized value $foo5[1] in sprintf at - line 8.
1034Use of uninitialized value $foo6[1] in sprintf at - line 9.
1035Use of uninitialized value $foo7{"baz"} in sprintf at - line 10.
1036Use of uninitialized value $foo8{"baz"} in sprintf at - line 11.
1037Use of uninitialized value $m1 in sprintf at - line 12.
1038Use of uninitialized value $foo9[1] in sprintf at - line 12.
1039Use of uninitialized value in sprintf at - line 12.
1040Use of uninitialized value $m2 in sprintf at - line 13.
1041Use of uninitialized value $foo10[1] in sprintf at - line 13.
1042Use of uninitialized value in sprintf at - line 13.
1043Use of uninitialized value $foo11{"baz"} in join or string at - line 14.
1044Use of uninitialized value $foo12{"baz"} in join or string at - line 15.
1045Use of uninitialized value within %foo13 in join or string at - line 16.
1046Use of uninitialized value within %foo14 in join or string at - line 17.
1047########
1048use warnings 'uninitialized';
1049my ($v);
1050
1051undef $^A; $v = $^A + ${^FOO}; # should output '^A' not chr(1)
1052*GLOB1 = *GLOB2;
1053$v = $GLOB1 + 1;
1054$v = $GLOB2 + 1;
1055EXPECT
1056Use of uninitialized value $^FOO in addition (+) at - line 4.
1057Use of uninitialized value $^A in addition (+) at - line 4.
1058Use of uninitialized value $GLOB1 in addition (+) at - line 6.
1059Use of uninitialized value $GLOB2 in addition (+) at - line 7.
1060########
1061use warnings 'uninitialized';
1062my ($v);
1063
1064# check hash key is sanitised
1065my %h = ("\0011\002\r\n\t\f\"\\abcdefghijklmnopqrstuvwxyz", undef);
1066$v = join '', %h;
1067EXPECT
3df15adc 1068Use of uninitialized value $h{"\0011\2\r\n\t\f\"\\abcdefghijklm"...} in join or string at - line 6.
29489e7c
DM
1069########
1070use warnings 'uninitialized';
1071my ($m1, $v);
1072our ($g1);
1073
1074$v = eval { \&$m1 };
1075$v = eval { \&$g1 };
1076
1077my @a;
1078@a = splice @a, $m1, $g1;
1079$v = 1 + splice @a, $m1, $g1;
1080
1081my $x = bless [], 'Z';
1082eval { $x->$m1() };
1083
1084eval { &$m1() };
1085eval { &$g1() };
1086
1087warn $m1,$g1,"foo";
1088
1089eval { die $m1, $g1 };
1090
1091reset $m1;
1092reset $g1;
1093EXPECT
1094Use of uninitialized value $m1 in subroutine dereference at - line 5.
29489e7c
DM
1095Use of uninitialized value $g1 in subroutine dereference at - line 6.
1096Use of uninitialized value $m1 in splice at - line 9.
1097Use of uninitialized value $g1 in splice at - line 9.
1098Use of uninitialized value $m1 in splice at - line 10.
1099Use of uninitialized value $g1 in splice at - line 10.
1100Use of uninitialized value in addition (+) at - line 10.
1101Use of uninitialized value $m1 in method lookup at - line 13.
7697b7e7
DM
1102Use of uninitialized value in subroutine entry at - line 15.
1103Use of uninitialized value in subroutine entry at - line 16.
29489e7c
DM
1104Use of uninitialized value $m1 in warn at - line 18.
1105Use of uninitialized value $g1 in warn at - line 18.
1106foo at - line 18.
1107Use of uninitialized value $m1 in die at - line 20.
1108Use of uninitialized value $g1 in die at - line 20.
1109Use of uninitialized value $m1 in symbol reset at - line 22.
1110Use of uninitialized value $g1 in symbol reset at - line 23.
1111########
1112use warnings 'uninitialized';
1113my ($m1);
1114our ($g1);
1115
1116open FOO; # accesses $FOO
1117my $foo = 'FO';
1118open($foo."O"); # accesses $FOO
1119open my $x; # accesses ${*$x}
1120open $foobar; # accesses ${*$foobar}
1121my $y;
1122open $y, $m1;
1123eval { open $y, $m1, $g1 };
1124open $y, '<', $g1;
1125
1126sysopen $y, $m1, $m2;
1127sysopen $y, $m1, $g1, $m2;
1128
1129my $old = umask;
1130umask $m1;
1131umask $g1;
1132umask $old;
1133
1134binmode STDIN, $m1;
1135EXPECT
1136Use of uninitialized value $FOO in open at - line 5.
1137Use of uninitialized value in open at - line 7.
1138Use of uninitialized value in open at - line 8.
1139Use of uninitialized value in open at - line 9.
1140Use of uninitialized value $m1 in open at - line 11.
1141Use of uninitialized value $m1 in open at - line 12.
1142Use of uninitialized value $g1 in open at - line 13.
1143Use of uninitialized value $m2 in sysopen at - line 15.
1144Use of uninitialized value $m1 in sysopen at - line 15.
1145Use of uninitialized value $m2 in sysopen at - line 16.
1146Use of uninitialized value $g1 in sysopen at - line 16.
1147Use of uninitialized value $m1 in sysopen at - line 16.
1148Use of uninitialized value $m1 in umask at - line 19.
1149Use of uninitialized value $g1 in umask at - line 20.
1150Use of uninitialized value $m1 in binmode at - line 23.
29489e7c
DM
1151########
1152use warnings 'uninitialized';
1153my ($m1);
1154our ($g1);
1155
1156eval { my $x; tie $x, $m1 };
1157
1158eval { my $x; read $m1, $x, $g1 };
1159eval { my $x; read $m1, $x, $g1, $g2 };
1160eval { my $x; sysread $m1, $x, $g1 };
1161eval { my $x; sysread $m1, $x, $g1, $g2 };
1162EXPECT
1163Use of uninitialized value $m1 in tie at - line 5.
29489e7c
DM
1164Use of uninitialized value $m1 in ref-to-glob cast at - line 7.
1165Use of uninitialized value $g1 in read at - line 7.
1166Use of uninitialized value $m1 in ref-to-glob cast at - line 8.
1167Use of uninitialized value $g1 in read at - line 8.
1168Use of uninitialized value $g2 in read at - line 8.
1169Use of uninitialized value $m1 in ref-to-glob cast at - line 9.
1170Use of uninitialized value $g1 in sysread at - line 9.
1171Use of uninitialized value $m1 in ref-to-glob cast at - line 10.
1172Use of uninitialized value $g1 in sysread at - line 10.
1173Use of uninitialized value $g2 in sysread at - line 10.
1174########
1175use warnings 'uninitialized';
1176my ($m1);
1177our ($g1, @ga);
1178
1179printf $m1;
1180printf STDERR "%d%d%d%d\n", $m1, $m2, $g1, $g2;
1181printf $ga[1000];
1182printf STDERR "FOO1:%s\n", $ga[1000];
1183printf STDERR "FOO2:%s%s%s%s\n", $m1, $g1, $ga[1],$m2;
1184printf STDERR "FOO3:%s%s%s\n", "X", $ga[1],"Y";
1185EXPECT
1186Use of uninitialized value $m1 in printf at - line 5.
1187Use of uninitialized value $m1 in printf at - line 6.
1188Use of uninitialized value $m2 in printf at - line 6.
1189Use of uninitialized value $g1 in printf at - line 6.
1190Use of uninitialized value $g2 in printf at - line 6.
11910000
fa8d1836
DM
1192Use of uninitialized value in printf at - line 7.
1193Use of uninitialized value in printf at - line 8.
29489e7c
DM
1194FOO1:
1195Use of uninitialized value $m1 in printf at - line 9.
1196Use of uninitialized value $g1 in printf at - line 9.
1197Use of uninitialized value in printf at - line 9.
1198Use of uninitialized value $m2 in printf at - line 9.
1199FOO2:
fa8d1836 1200Use of uninitialized value in printf at - line 10.
29489e7c
DM
1201FOO3:XY
1202########
1203use warnings 'uninitialized';
1204my ($m1);
1205our ($g1);
1206
1207eval { my $x; seek $x,$m1, $g1 };
1208eval { my $x; sysseek $x,$m1, $g1 };
c9cb0f41 1209eval { syswrite $m1, $g1 }; # logic changed - now won't try $g1 if $m1 is bad
96d52181
DM
1210# eval { syswrite STDERR, $m1 }; # XXX under utf8, can give
1211# eval { syswrite STDERR, $m1, $g1 }; # XXX different warnings
1212# eval { syswrite STDERR, $m1, $g1, $m2 };
29489e7c
DM
1213eval { my $x; socket $x, $m1, $g1, $m2 };
1214eval { my ($x,$y); socketpair $x, $y, $m1, $g1, $m2 };
1215EXPECT
1216Use of uninitialized value $x in ref-to-glob cast at - line 5.
1217Use of uninitialized value $g1 in seek at - line 5.
1218Use of uninitialized value $m1 in seek at - line 5.
1219Use of uninitialized value $x in ref-to-glob cast at - line 6.
1220Use of uninitialized value $g1 in sysseek at - line 6.
1221Use of uninitialized value $m1 in sysseek at - line 6.
1222Use of uninitialized value $m1 in ref-to-glob cast at - line 7.
c162e49a
CB
1223Use of uninitialized value $m2 in socket at - line 11.
1224Use of uninitialized value $g1 in socket at - line 11.
1225Use of uninitialized value $m1 in socket at - line 11.
1226Use of uninitialized value $m2 in socketpair at - line 12.
1227Use of uninitialized value $g1 in socketpair at - line 12.
1228Use of uninitialized value $m1 in socketpair at - line 12.
1229########
1230use Config;
1231BEGIN {
1232 if ( !$Config{d_flock} &&
1233 !$Config{d_fcntl_can_lock} &&
1234 !$Config{d_lockf} ) {
1235 print <<EOM ;
1236SKIPPED
1237# flock not present
1238EOM
1239 exit ;
1240 }
1241}
1242use warnings 'uninitialized';
1243our ($g1);
1244
1245eval { my $x; flock $x, $g1 };
1246EXPECT
1247Use of uninitialized value $x in ref-to-glob cast at - line 16.
1248Use of uninitialized value $g1 in flock at - line 16.
29489e7c
DM
1249########
1250use warnings 'uninitialized';
1251my ($m1, $v);
1252our ($g1);
1253
1254stat;
1255lstat;
1256stat $m1;
1257lstat $g1;
1258
1259$v = -R $m1;
1260$v = -W $m1;
1261$v = -X $m1;
1262$v = -r $m1;
1263$v = -w $m1;
1264$v = -x $m1;
1265$v = -e $m1;
29489e7c 1266$v = -o $m1;
945fa9b5 1267$v = -O $m1;
29489e7c
DM
1268$v = -z $m1;
1269$v = -s $m1;
1270$v = -M $m1;
1271$v = -A $m1;
1272$v = -C $m1;
1273$v = -S $m1;
1274$v = -c $m1;
1275$v = -b $m1;
1276$v = -f $m1;
1277$v = -d $m1;
1278$v = -p $m1;
1279$v = -l $m1;
1280$v = -u $m1;
1281$v = -g $m1;
96d52181 1282# $v = -k $m1; # XXX this is a no-op under win32
29489e7c
DM
1283$v = -t $m1;
1284$v = -T $m1;
1285$v = -B $m1;
1286EXPECT
1287Use of uninitialized value $_ in stat at - line 5.
1288Use of uninitialized value $_ in lstat at - line 6.
1289Use of uninitialized value $m1 in stat at - line 7.
1290Use of uninitialized value $g1 in lstat at - line 8.
1291Use of uninitialized value $m1 in -R at - line 10.
1292Use of uninitialized value $m1 in -W at - line 11.
1293Use of uninitialized value $m1 in -X at - line 12.
1294Use of uninitialized value $m1 in -r at - line 13.
1295Use of uninitialized value $m1 in -w at - line 14.
1296Use of uninitialized value $m1 in -x at - line 15.
1297Use of uninitialized value $m1 in -e at - line 16.
1298Use of uninitialized value $m1 in -o at - line 17.
1299Use of uninitialized value $m1 in -O at - line 18.
1300Use of uninitialized value $m1 in -z at - line 19.
1301Use of uninitialized value $m1 in -s at - line 20.
1302Use of uninitialized value $m1 in -M at - line 21.
1303Use of uninitialized value $m1 in -A at - line 22.
1304Use of uninitialized value $m1 in -C at - line 23.
1305Use of uninitialized value $m1 in -S at - line 24.
1306Use of uninitialized value $m1 in -c at - line 25.
1307Use of uninitialized value $m1 in -b at - line 26.
1308Use of uninitialized value $m1 in -f at - line 27.
1309Use of uninitialized value $m1 in -d at - line 28.
1310Use of uninitialized value $m1 in -p at - line 29.
1311Use of uninitialized value $m1 in -l at - line 30.
29489e7c
DM
1312Use of uninitialized value $m1 in -u at - line 31.
1313Use of uninitialized value $m1 in -g at - line 32.
29489e7c
DM
1314Use of uninitialized value $m1 in -t at - line 34.
1315Use of uninitialized value $m1 in -T at - line 35.
1316Use of uninitialized value $m1 in -B at - line 36.
1317########
1318use warnings 'uninitialized';
1319my ($m1, $v);
1320our ($g1);
1321
1322$v = localtime $m1;
1323$v = gmtime $g1;
1324EXPECT
1325Use of uninitialized value $m1 in localtime at - line 5.
1326Use of uninitialized value $g1 in gmtime at - line 6.
1327########
1328use warnings 'uninitialized';
50edf520 1329my ($m1, $m2, $v);
29489e7c
DM
1330
1331$v = eval;
1332$v = eval $m1;
50edf520 1333$m2 = q($m1); $v = 1 + eval $m2;
29489e7c
DM
1334EXPECT
1335Use of uninitialized value $_ in eval "string" at - line 4.
29489e7c 1336Use of uninitialized value $m1 in eval "string" at - line 5.
50edf520 1337Use of uninitialized value in addition (+) at - line 6.
29489e7c
DM
1338########
1339use warnings 'uninitialized';
1340my ($m1);
1341
1342exit $m1;
1343EXPECT
1344Use of uninitialized value $m1 in exit at - line 4.
12e06b6f 1345########
12e06b6f
NC
1346use warnings 'uninitialized';
1347my $undef;
1348
1349if ($undef == 3) {
1350} elsif ($undef == 0) {
1351}
1352EXPECT
1353Use of uninitialized value $undef in numeric eq (==) at - line 4.
1354Use of uninitialized value $undef in numeric eq (==) at - line 5.
1355########
79851868
NC
1356# TODO long standing bug - conditions of while loops
1357use warnings;
1358
1359my $c;
1360my $d = 1;
1361while ($c == 0 && $d) {
1362 # a
1363 # few
1364 # blank
1365 # lines
1366 undef $d;
1367}
1368EXPECT
1369Use of uninitialized value $c in numeric eq (==) at - line 5.
1370Use of uninitialized value $c in numeric eq (==) at - line 5.
1371########
d12f7a6a
NC
1372# TODO long standing bug - conditions of until loops
1373use warnings;
1374
1375my $c;
1376my $d;
1377until ($c == 1) {
1378 # a
1379 # few
1380 # blank
1381 # lines
1382 $c = 1 if ++$d == 2;
1383}
1384EXPECT
1385Use of uninitialized value $c in numeric eq (==) at - line 5.
1386Use of uninitialized value $c in numeric eq (==) at - line 5.
1387########
1388# TODO long standing bug - conditions of for loops
1389use warnings;
1390
1391my $c;
1392my $d;
1393for ($d = 1; $c == 0 && $d; ) {
1394 # a
1395 # few
1396 # blank
1397 # lines
1398 undef $d;
1399}
1400
1401my $e;
1402for ($d = 2; $d > 0; $e = !($c == 0)) {
1403 # a
1404 # few
1405 # blank
1406 # lines
1407 --$d;
1408}
1409EXPECT
1410Use of uninitialized value $c in numeric eq (==) at - line 5.
1411Use of uninitialized value $c in numeric eq (==) at - line 5.
1412Use of uninitialized value $c in numeric eq (==) at - line 14.
1413Use of uninitialized value $c in numeric eq (==) at - line 14.
1414########
12e06b6f
NC
1415# TODO long standing bug - more general variant of the above problem
1416use warnings;
1417my $undef;
1418
1419my $a = $undef + 1;
1420my $b
1421 = $undef
1422 + 1;
1423EXPECT
1424Use of uninitialized value $undef in addition (+) at - line 4.
1425Use of uninitialized value $undef in addition (+) at - line 7.
1e21d011
B
1426########
1427use warnings 'uninitialized';
1428my ($r1, $r2);
1429$_ = undef;
1430$v = reverse;
1431$v = reverse $r1;
1432$v = reverse "abc", $r2, "def";
1433EXPECT
1434Use of uninitialized value in reverse at - line 4.
1435Use of uninitialized value $r1 in reverse at - line 5.
1436Use of uninitialized value $r2 in reverse at - line 6.
8b0dea50
DM
1437########
1438use warnings 'uninitialized';
1439#
1440# ops that can return undef for defined args
0b9c91f6 1441# split into separate tests to diagnose the cause of daily build smoke
8b0dea50 1442#
928cb7d4 1443# *** `` not tested: Windows produces an error on STDERR
a3ed38f2 1444# *** ditto qx()
8b0dea50 1445# *** pipe() not tested
8b0dea50
DM
1446# *** ioctl not tested
1447# *** socket not tested
1448# *** socketpair not tested
1449# *** bind not tested
1450# *** connect not tested
1451# *** listen not tested
8b0dea50
DM
1452# *** shutdown not tested
1453# *** setsockopt not tested
1454# *** getpeername not tested
0b9c91f6
NC
1455# *** readdir not tested
1456# *** telldir not tested
1457# *** seekdir not tested
1458# *** rewinddir not tested
1459# *** closedir not tested
1460# *** gmtime not tested
1461# *** alarm not tested
1462# *** semget not tested
1463# *** getlogin not tested
1464EXPECT
1465########
1466use warnings 'uninitialized';
2234743e
NC
1467if ($^O eq 'MSWin32') {
1468 print <<'EOM';
1469SKIPPED
1470# `` produces an error on STDERR on Win32
1471EOM
1472 exit;
1473}
1474my $nocmd = '/no/such/command';
1475my $v;
1476$v = 1 + `$nocmd`;
1477EXPECT
1478Use of uninitialized value in addition (+) at - line 11.
1479########
1480use warnings 'uninitialized';
1481if ($^O eq 'MSWin32') {
1482 print <<'EOM';
1483SKIPPED
1484# qx produces an error on STDERR on Win32
1485EOM
1486 exit;
1487}
1488my $nocmd = '/no/such/command';
1489my $v;
1490$v = 1 + qx($nocmd);
1491EXPECT
1492Use of uninitialized value in addition (+) at - line 11.
1493########
1494use warnings 'uninitialized';
1495my $nan = "NaN";
1496if ($nan == $nan) {
1497 print <<'EOM';
1498SKIPPED
1499# NaN not supported here.
1500EOM
1501 exit;
1502}
1503my $v;
1504$v = 1 + ($nan <=> 1);
1505EXPECT
1506Use of uninitialized value in addition (+) at - line 11.
1507########
1508use warnings 'uninitialized';
1509if ($^O eq 'MSWin32') {
1510 print <<'EOM';
1511SKIPPED
1512# -k produces no warning on Win32
1513EOM
1514 exit;
1515}
1516my $nofile = '/no/such/file';
1517my $v;
1518$v = 1 + -k $nofile;
1519EXPECT
1520Use of uninitialized value in addition (+) at - line 11.
1521########
1522use warnings 'uninitialized';
0b9c91f6
NC
1523my $nofile = '/no/such/file';
1524my $v;
1525my $f = "";
1526$v = 1 + open($f, $nofile);
1527EXPECT
1528Use of uninitialized value in addition (+) at - line 5.
1529########
1530use warnings 'uninitialized';
1531my $nofile = '/no/such/file';
1532my $v;
1533$v = 1 + fileno($nofile);
1534EXPECT
1535Use of uninitialized value in addition (+) at - line 4.
1536########
1537use warnings 'uninitialized';
1538my $nofile = '/no/such/file';
1539my $v;
1540$v = 1 + binmode($nofile);
1541EXPECT
1542Use of uninitialized value in addition (+) at - line 4.
1543########
1544use warnings 'uninitialized';
1545my $nofile = '/no/such/file';
1546my $v;
1547$v = 1 + tied($nofile);
1548EXPECT
1549Use of uninitialized value in addition (+) at - line 4.
1550########
1551use warnings 'uninitialized';
1552my $nofile = '/no/such/file';
1553my $v;
1554$v = 1 + getc($nofile);
1555EXPECT
1556Use of uninitialized value in addition (+) at - line 4.
1557########
1558use warnings 'uninitialized';
1559my $nofile = '/no/such/file';
1560my $v;
1561$v = 1 + sysread($nofile, my $buf,1);
1562EXPECT
1563Use of uninitialized value in addition (+) at - line 4.
1564########
1565use warnings 'uninitialized';
1566my $nofile = '/no/such/file';
1567my $v;
1568$v = 1 + eval { send($nofile, $buf,0) };
1569EXPECT
1570Use of uninitialized value in addition (+) at - line 4.
1571########
1572use warnings 'uninitialized';
1573my $nofile = '/no/such/file';
1574my $v;
1575my $fh = "";
1576$v = 1 + eval { accept($fh, $nofile) };
1577EXPECT
1578Use of uninitialized value in addition (+) at - line 5.
1579########
1580use warnings 'uninitialized';
1581my $nofile = '/no/such/file';
1582my $v;
8b0dea50 1583$v = 1 + (-r $nofile);
0b9c91f6
NC
1584EXPECT
1585Use of uninitialized value in addition (+) at - line 4.
1586########
1587use warnings 'uninitialized';
1588my $nofile = '/no/such/file';
1589my $v;
8b0dea50 1590$v = 1 + (-w $nofile);
0b9c91f6
NC
1591EXPECT
1592Use of uninitialized value in addition (+) at - line 4.
1593########
1594use warnings 'uninitialized';
1595my $nofile = '/no/such/file';
1596my $v;
8b0dea50 1597$v = 1 + (-x $nofile);
0b9c91f6
NC
1598EXPECT
1599Use of uninitialized value in addition (+) at - line 4.
1600########
1601use warnings 'uninitialized';
1602my $nofile = '/no/such/file';
1603my $v;
8b0dea50 1604$v = 1 + (-o $nofile);
0b9c91f6
NC
1605EXPECT
1606Use of uninitialized value in addition (+) at - line 4.
1607########
1608use warnings 'uninitialized';
1609my $nofile = '/no/such/file';
1610my $v;
8b0dea50 1611$v = 1 + (-R $nofile);
0b9c91f6
NC
1612EXPECT
1613Use of uninitialized value in addition (+) at - line 4.
1614########
1615use warnings 'uninitialized';
1616my $nofile = '/no/such/file';
1617my $v;
8b0dea50 1618$v = 1 + (-W $nofile);
0b9c91f6
NC
1619EXPECT
1620Use of uninitialized value in addition (+) at - line 4.
1621########
1622use warnings 'uninitialized';
1623my $nofile = '/no/such/file';
1624my $v;
8b0dea50 1625$v = 1 + (-X $nofile);
0b9c91f6
NC
1626EXPECT
1627Use of uninitialized value in addition (+) at - line 4.
1628########
1629use warnings 'uninitialized';
1630my $nofile = '/no/such/file';
1631my $v;
8b0dea50 1632$v = 1 + (-O $nofile);
0b9c91f6
NC
1633EXPECT
1634Use of uninitialized value in addition (+) at - line 4.
1635########
1636use warnings 'uninitialized';
1637my $nofile = '/no/such/file';
1638my $v;
8b0dea50 1639$v = 1 + (-e $nofile);
0b9c91f6
NC
1640EXPECT
1641Use of uninitialized value in addition (+) at - line 4.
1642########
1643use warnings 'uninitialized';
1644my $nofile = '/no/such/file';
1645my $v;
8b0dea50 1646$v = 1 + (-z $nofile);
0b9c91f6
NC
1647EXPECT
1648Use of uninitialized value in addition (+) at - line 4.
1649########
1650use warnings 'uninitialized';
1651my $nofile = '/no/such/file';
1652my $v;
8b0dea50 1653$v = 1 + (-s $nofile);
0b9c91f6
NC
1654EXPECT
1655Use of uninitialized value in addition (+) at - line 4.
1656########
1657use warnings 'uninitialized';
1658my $nofile = '/no/such/file';
1659my $v;
8b0dea50 1660$v = 1 + (-f $nofile);
0b9c91f6
NC
1661EXPECT
1662Use of uninitialized value in addition (+) at - line 4.
1663########
1664use warnings 'uninitialized';
1665my $nofile = '/no/such/file';
1666my $v;
8b0dea50 1667$v = 1 + (-d $nofile);
0b9c91f6
NC
1668EXPECT
1669Use of uninitialized value in addition (+) at - line 4.
1670########
1671use warnings 'uninitialized';
1672my $nofile = '/no/such/file';
1673my $v;
8b0dea50 1674$v = 1 + (-l $nofile);
0b9c91f6
NC
1675EXPECT
1676Use of uninitialized value in addition (+) at - line 4.
1677########
1678use warnings 'uninitialized';
1679my $nofile = '/no/such/file';
1680my $v;
8b0dea50 1681$v = 1 + (-p $nofile);
0b9c91f6
NC
1682EXPECT
1683Use of uninitialized value in addition (+) at - line 4.
1684########
1685use warnings 'uninitialized';
1686my $nofile = '/no/such/file';
1687my $v;
8b0dea50 1688$v = 1 + (-S $nofile);
0b9c91f6
NC
1689EXPECT
1690Use of uninitialized value in addition (+) at - line 4.
1691########
1692use warnings 'uninitialized';
1693my $nofile = '/no/such/file';
1694my $v;
8b0dea50 1695$v = 1 + (-b $nofile);
0b9c91f6
NC
1696EXPECT
1697Use of uninitialized value in addition (+) at - line 4.
1698########
1699use warnings 'uninitialized';
1700my $nofile = '/no/such/file';
1701my $v;
8b0dea50 1702$v = 1 + (-c $nofile);
0b9c91f6
NC
1703EXPECT
1704Use of uninitialized value in addition (+) at - line 4.
1705########
1706use warnings 'uninitialized';
1707my $nofile = '/no/such/file';
1708my $v;
8b0dea50 1709$v = 1 + (-t $nofile);
0b9c91f6
NC
1710EXPECT
1711Use of uninitialized value in addition (+) at - line 4.
1712########
1713use warnings 'uninitialized';
1714my $nofile = '/no/such/file';
1715my $v;
8b0dea50 1716$v = 1 + (-u $nofile);
0b9c91f6
NC
1717EXPECT
1718Use of uninitialized value in addition (+) at - line 4.
1719########
1720use warnings 'uninitialized';
1721my $nofile = '/no/such/file';
1722my $v;
8b0dea50 1723$v = 1 + (-g $nofile);
0b9c91f6
NC
1724EXPECT
1725Use of uninitialized value in addition (+) at - line 4.
1726########
1727use warnings 'uninitialized';
1728my $nofile = '/no/such/file';
1729my $v;
8b0dea50 1730$v = 1 + (-T $nofile);
0b9c91f6
NC
1731EXPECT
1732Use of uninitialized value in addition (+) at - line 4.
1733########
1734use warnings 'uninitialized';
1735my $nofile = '/no/such/file';
1736my $v;
8b0dea50 1737$v = 1 + (-B $nofile);
0b9c91f6
NC
1738EXPECT
1739Use of uninitialized value in addition (+) at - line 4.
1740########
1741use warnings 'uninitialized';
1742my $nofile = '/no/such/file';
1743my $v;
8b0dea50 1744$v = 1 + (-M $nofile);
0b9c91f6
NC
1745EXPECT
1746Use of uninitialized value in addition (+) at - line 4.
1747########
1748use warnings 'uninitialized';
1749my $nofile = '/no/such/file';
1750my $v;
8b0dea50 1751$v = 1 + (-A $nofile);
0b9c91f6
NC
1752EXPECT
1753Use of uninitialized value in addition (+) at - line 4.
1754########
1755use warnings 'uninitialized';
1756my $nofile = '/no/such/file';
1757my $v;
8b0dea50 1758$v = 1 + (-C $nofile);
0b9c91f6
NC
1759EXPECT
1760Use of uninitialized value in addition (+) at - line 4.
1761########
1762use warnings 'uninitialized';
1763my $nofile = '/no/such/file';
1764my $v;
8b0dea50 1765$v = 1 + eval { readlink $nofile };
0b9c91f6
NC
1766EXPECT
1767Use of uninitialized value in addition (+) at - line 4.
1768########
1769use warnings 'uninitialized';
1770my $nofile = '/no/such/file';
1771my $v;
8b0dea50 1772$v = 1 + opendir($f, $nofile);
0b9c91f6
NC
1773EXPECT
1774Use of uninitialized value in addition (+) at - line 4.
1775########
1776use warnings 'uninitialized';
1777my $nofile = '/no/such/file';
1778my $v;
8b0dea50 1779$v = 1 + undef;
0b9c91f6
NC
1780EXPECT
1781Use of uninitialized value in addition (+) at - line 4.
1782########
1783use warnings 'uninitialized';
1784my $nofile = '/no/such/file';
1785my $v;
8b0dea50 1786my $x = 1; $v = 1 + undef($x);
0b9c91f6
NC
1787EXPECT
1788Use of uninitialized value in addition (+) at - line 4.
1789########
1790use warnings 'uninitialized';
1791my $v;
8b0dea50
DM
1792my $emptys = "";
1793$v = 1 + substr($emptys,2,1);
0b9c91f6
NC
1794EXPECT
1795Use of uninitialized value in addition (+) at - line 4.
1796########
1797use warnings 'uninitialized';
1798my $v;
8b0dea50
DM
1799my @emptya;
1800$v = 1 + each @emptya;
0b9c91f6
NC
1801EXPECT
1802Use of uninitialized value in addition (+) at - line 4.
1803########
1804use warnings 'uninitialized';
1805my $v;
1806my %emptyh;
8b0dea50 1807$v = 1 + each %emptyh;
0b9c91f6
NC
1808EXPECT
1809Use of uninitialized value in addition (+) at - line 4.
1810########
1811use warnings 'uninitialized';
1812my $v;
1813my @emptya;
8b0dea50 1814$v = 1 + sort @emptya;
0b9c91f6
NC
1815EXPECT
1816Use of uninitialized value in addition (+) at - line 4.
1817########
1818use warnings 'uninitialized';
1819my $v;
8b0dea50 1820my $zero = 0; $v = 1 + caller($zero);
0b9c91f6
NC
1821EXPECT
1822Use of uninitialized value in addition (+) at - line 3.
1823########
1824use warnings 'uninitialized';
1825my $nofile = '/no/such/file';
1826my $v;
8b0dea50 1827$v = 1 + do $nofile;
0b9c91f6
NC
1828EXPECT
1829Use of uninitialized value in addition (+) at - line 4.
1830########
1831use warnings 'uninitialized';
1832my $v;
fa8d1836
DM
1833my $fn = sub {};
1834$v = 1 + prototype $fn;
0b9c91f6
NC
1835EXPECT
1836Use of uninitialized value in addition (+) at - line 4.
1837########
1838use warnings 'uninitialized';
1839my $v;
1840my $fn = sub {};
6ac83b63 1841$v = 1 + (1 ~~ $fn);
0b9c91f6
NC
1842EXPECT
1843Use of uninitialized value in addition (+) at - line 4.
1844########
1845use warnings 'uninitialized';
1846my $v;
1847my $f = "";
fa8d1836 1848$v = 1 + (print STDIN $f); # print to STDIN returns undef
0b9c91f6
NC
1849EXPECT
1850Use of uninitialized value in addition (+) at - line 4.
1851########
1852use warnings 'uninitialized';
1853my $v;
1854my $f = "";
fa8d1836 1855$v = 1 + (printf STDIN "%s", $f);
0b9c91f6
NC
1856EXPECT
1857Use of uninitialized value in addition (+) at - line 4.
1858########
1859use warnings 'uninitialized';
1860my $v;
1861my $f = "";
fa8d1836 1862{ use feature 'say'; $v = 1 + (say STDIN "%s", $f); }
0b9c91f6
NC
1863EXPECT
1864Use of uninitialized value in addition (+) at - line 4.
1865########
1866use warnings 'uninitialized';
1867my $v;
1868my $f = "";
fa8d1836 1869$v = 1 + (unpack("",$f));
0b9c91f6
NC
1870EXPECT
1871Use of uninitialized value in addition (+) at - line 4.
1872########
1873use warnings 'uninitialized';
1874my $nofile = '/no/such/file';
1875my $v;
1876my $f = "";
fa8d1836 1877$v = 1 + sysopen($f, $nofile, 0);
0b9c91f6
NC
1878EXPECT
1879Use of uninitialized value in addition (+) at - line 5.
1880########
1881use warnings 'uninitialized';
1882my $v;
fa8d1836 1883{ my $x = -1; $v = 1 + sysseek(STDIN, $x, 0); }
8b0dea50 1884EXPECT
0b9c91f6 1885Use of uninitialized value in addition (+) at - line 3.