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