This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix for [perl #9423] vec assignments generate 2 warnings
[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.
3c323193 533Use of uninitialized value $m1 in range (or flop) at - line 9.
c774086b 534Use of uninitialized value $m2 in range (or flop) at - line 9.
93398190
VP
535Use of uninitialized value $m1 in range (or flop) at - line 12.
536Use of uninitialized value $m2 in range (or flop) at - line 13.
3c323193 537Use of uninitialized value $m1 in range (or flop) at - line 14.
c774086b 538Use of uninitialized value $m2 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;
a9ea019a
FC
638@sort = sort pyfg 1, 2;
639@sort = sort pyfgc 1, 2;
640no warnings;
641sub pyfg { undef }
642sub pyfgc($$) { undef }
1715fa64
FC
643use warnings;
644sub dog {}
645sub dogwood($$) {}
646@sort = sort dog 1,2;
647@sort = sort dogwood 1,2;
29489e7c
DM
648EXPECT
649Use of uninitialized value $m1 in sort at - line 6.
650Use of uninitialized value $g1 in sort at - line 6.
651Use of uninitialized value $m1 in sort at - line 6.
652Use of uninitialized value $g1 in sort at - line 6.
653Use of uninitialized value $m1 in sort at - line 7.
654Use of uninitialized value $g1 in sort at - line 7.
655Use of uninitialized value $m1 in sort at - line 7.
656Use of uninitialized value $g1 in sort at - line 7.
657Use of uninitialized value $a in subtraction (-) at - line 8.
658Use of uninitialized value $b in subtraction (-) at - line 8.
659Use of uninitialized value $m1 in sort at - line 9.
660Use of uninitialized value $g1 in sort at - line 9.
661Use of uninitialized value $m1 in sort at - line 9.
662Use of uninitialized value $m1 in sort at - line 9.
663Use of uninitialized value $g1 in sort at - line 9.
664Use of uninitialized value $g1 in sort at - line 9.
d4c6760a 665Use of uninitialized value in sort at - line 10.
a9ea019a
FC
666Use of uninitialized value in sort at - line 12.
667Use of uninitialized value in sort at - line 13.
668Use of uninitialized value in sort at - line 14.
1715fa64
FC
669Use of uninitialized value in sort at - line 21.
670Use of uninitialized value in sort at - line 22.
29489e7c 671########
f3dab52a
FC
672my $nan = sin 9**9**9;
673if ($nan == $nan) {
674 print <<EOM ;
675SKIPPED
676# No nan support
677EOM
678 exit ;
679}
680use warnings 'uninitialized';
681# The optimised {$a<=>$b} case should behave the same way as unoptimised.
682@sort = sort { ($a)[0] <=> $b } 1, $nan;
683@sort = sort { $a <=> $b } 1, $nan;
684EXPECT
685Use of uninitialized value in sort at - line 11.
686Use of uninitialized value in sort at - line 12.
687########
29489e7c
DM
688use warnings 'uninitialized';
689my ($m1, $m2, $v);
690our ($g1);
691
692eval { $v = $m1 / $g1 };
693$v = $m2 / 2;
694eval { $v = $m1 % $g1 };
695$v = $m2 % 2;
696$v = $m1 == $g1;
697$v = $m1 >= $g1;
698$v = $m1 > $g1;
699$v = $m1 <= $g1;
700$v = $m1 < $g1;
701$v = $m1 * $g1;
702$v = $m1 <=>$g1;
703$v = $m1 != $g1;
704$v = $m1 -$g1;
705$v = $m1 ** $g1;
706$v = $m1 + $g1;
707$v = $m1 - $g1;
708EXPECT
709Use of uninitialized value $g1 in division (/) at - line 5.
710Use of uninitialized value $m1 in division (/) at - line 5.
711Use of uninitialized value $m2 in division (/) at - line 6.
712Use of uninitialized value $g1 in modulus (%) at - line 7.
713Use of uninitialized value $m1 in modulus (%) at - line 7.
714Use of uninitialized value $m2 in modulus (%) at - line 8.
715Use of uninitialized value $g1 in numeric eq (==) at - line 9.
716Use of uninitialized value $m1 in numeric eq (==) at - line 9.
717Use of uninitialized value $g1 in numeric ge (>=) at - line 10.
718Use of uninitialized value $m1 in numeric ge (>=) at - line 10.
719Use of uninitialized value $g1 in numeric gt (>) at - line 11.
720Use of uninitialized value $m1 in numeric gt (>) at - line 11.
721Use of uninitialized value $g1 in numeric le (<=) at - line 12.
722Use of uninitialized value $m1 in numeric le (<=) at - line 12.
723Use of uninitialized value $g1 in numeric lt (<) at - line 13.
724Use of uninitialized value $m1 in numeric lt (<) at - line 13.
725Use of uninitialized value $g1 in multiplication (*) at - line 14.
726Use of uninitialized value $m1 in multiplication (*) at - line 14.
727Use of uninitialized value $g1 in numeric comparison (<=>) at - line 15.
728Use of uninitialized value $m1 in numeric comparison (<=>) at - line 15.
729Use of uninitialized value $g1 in numeric ne (!=) at - line 16.
730Use of uninitialized value $m1 in numeric ne (!=) at - line 16.
731Use of uninitialized value $g1 in subtraction (-) at - line 17.
732Use of uninitialized value $m1 in subtraction (-) at - line 17.
733Use of uninitialized value $g1 in exponentiation (**) at - line 18.
734Use of uninitialized value $m1 in exponentiation (**) at - line 18.
735Use of uninitialized value $g1 in addition (+) at - line 19.
736Use of uninitialized value $m1 in addition (+) at - line 19.
737Use of uninitialized value $g1 in subtraction (-) at - line 20.
738Use of uninitialized value $m1 in subtraction (-) at - line 20.
739########
740use warnings 'uninitialized';
4c3ac4ba
FC
741sub TIESCALAR{bless[]}
742sub FETCH { undef }
743
744tie my $m1, "";
7d779b23
FC
745my $v;
746$v = $m1 + $m1;
747$v = $m1 - $m1;
837c8798
FC
748no warnings;
749$v = $m1 + $m1;
7d779b23 750$v = $m1 - $m1;
4c3ac4ba 751EXPECT
7d779b23
FC
752Use of uninitialized value $m1 in addition (+) at - line 7.
753Use of uninitialized value $m1 in addition (+) at - line 7.
754Use of uninitialized value $m1 in subtraction (-) at - line 8.
755Use of uninitialized value $m1 in subtraction (-) at - line 8.
4c3ac4ba
FC
756########
757use warnings 'uninitialized';
29489e7c
DM
758my ($m1, $v);
759our ($g1);
760
761$v = *global1{$m1};
762$v = prototype $g1;
763$v = bless [], $g1;
764$v = `$m1`;
765
766$v = $m1 . $g1;
767EXPECT
768Use of uninitialized value $m1 in glob elem at - line 5.
769Use of uninitialized value $g1 in subroutine prototype at - line 6.
770Use of uninitialized value $g1 in bless at - line 7.
771Use of uninitialized value $m1 in quoted execution (``, qx) at - line 8.
29489e7c 772Use of uninitialized value $m1 in concatenation (.) or string at - line 10.
c75ab21a 773Use of uninitialized value $g1 in concatenation (.) or string at - line 10.
29489e7c
DM
774########
775use warnings 'uninitialized';
776my ($m1);
777our ($g1, $g2);
778
779/y/;
780/$m1/;
781/$g1/;
782
783s/y/z/; undef $_;
784s/$m1/z/; undef $_;
785s//$g1/; undef $_;
786s/$m1/$g1/; undef $_;
787tr/x/y/; undef $_;
290797f7 788tr/x/y/r; undef $_;
29489e7c
DM
789
790my $_;
791/y/;
792/$m1/;
793/$g1/;
794s/y/z/; undef $_;
795s/$m1/z/; undef $_;
796s//$g1/; undef $_;
797s/$m1/$g1/; undef $_;
798tr/x/y/; undef $_;
290797f7 799tr/x/y/r; undef $_;
29489e7c
DM
800
801$g2 =~ /y/;
802$g2 =~ /$m1/;
803$g2 =~ /$g1/;
804$g2 =~ s/y/z/; undef $g2;
805$g2 =~ s/$m1/z/; undef $g2;
806$g2 =~ s//$g1/; undef $g2;
807$g2 =~ s/$m1/$g1/; undef $g2;
808$g2 =~ tr/x/y/; undef $g2; # XXX can't extract var name yet
290797f7 809$g2 =~ tr/x/y/r; undef $g2; # XXX can't extract var name yet
29489e7c
DM
810
811my $foo = "abc";
812$foo =~ /$m1/;
813$foo =~ /$g1/;
814$foo =~ s/y/z/;
815$foo =~ s/$m1/z/;
816$foo =~ s//$g1/;
817$foo =~ s/$m1/$g1/;
818$foo =~ s/./$m1/e;
50edf520
DM
819undef $g1;
820$m1 = '$g1';
821$foo =~ s//$m1/ee;
29489e7c
DM
822EXPECT
823Use of uninitialized value $_ in pattern match (m//) at - line 5.
824Use of uninitialized value $m1 in regexp compilation at - line 6.
825Use of uninitialized value $_ in pattern match (m//) at - line 6.
826Use of uninitialized value $g1 in regexp compilation at - line 7.
827Use of uninitialized value $_ in pattern match (m//) at - line 7.
828Use of uninitialized value $_ in substitution (s///) at - line 9.
829Use of uninitialized value $m1 in regexp compilation at - line 10.
830Use of uninitialized value $_ in substitution (s///) at - line 10.
831Use of uninitialized value $_ in substitution (s///) at - line 10.
832Use of uninitialized value $_ in substitution (s///) at - line 11.
833Use of uninitialized value $g1 in substitution (s///) at - line 11.
834Use of uninitialized value $_ in substitution (s///) at - line 11.
835Use of uninitialized value $g1 in substitution (s///) at - line 11.
836Use of uninitialized value $m1 in regexp compilation at - line 12.
837Use of uninitialized value $_ in substitution (s///) at - line 12.
838Use of uninitialized value $_ in substitution (s///) at - line 12.
839Use of uninitialized value $g1 in substitution iterator at - line 12.
840Use of uninitialized value $_ in transliteration (tr///) at - line 13.
290797f7 841Use of uninitialized value $_ in transliteration (tr///) at - line 14.
29489e7c 842Use of uninitialized value $_ in pattern match (m//) at - line 17.
290797f7 843Use of uninitialized value $m1 in regexp compilation at - line 18.
29489e7c 844Use of uninitialized value $_ in pattern match (m//) at - line 18.
290797f7
FC
845Use of uninitialized value $g1 in regexp compilation at - line 19.
846Use of uninitialized value $_ in pattern match (m//) at - line 19.
29489e7c 847Use of uninitialized value $_ in substitution (s///) at - line 20.
290797f7 848Use of uninitialized value $m1 in regexp compilation at - line 21.
29489e7c 849Use of uninitialized value $_ in substitution (s///) at - line 21.
29489e7c 850Use of uninitialized value $_ in substitution (s///) at - line 21.
29489e7c 851Use of uninitialized value $_ in substitution (s///) at - line 22.
290797f7 852Use of uninitialized value $g1 in substitution (s///) at - line 22.
29489e7c 853Use of uninitialized value $_ in substitution (s///) at - line 22.
290797f7
FC
854Use of uninitialized value $g1 in substitution (s///) at - line 22.
855Use of uninitialized value $m1 in regexp compilation at - line 23.
856Use of uninitialized value $_ in substitution (s///) at - line 23.
857Use of uninitialized value $_ in substitution (s///) at - line 23.
858Use of uninitialized value $g1 in substitution iterator at - line 23.
859Use of uninitialized value $_ in transliteration (tr///) at - line 24.
860Use of uninitialized value $_ in transliteration (tr///) at - line 25.
29489e7c 861Use of uninitialized value $g2 in pattern match (m//) at - line 27.
290797f7
FC
862Use of uninitialized value $m1 in regexp compilation at - line 28.
863Use of uninitialized value $g2 in pattern match (m//) at - line 28.
864Use of uninitialized value $g1 in regexp compilation at - line 29.
865Use of uninitialized value $g2 in pattern match (m//) at - line 29.
29489e7c 866Use of uninitialized value $g2 in substitution (s///) at - line 30.
29489e7c
DM
867Use of uninitialized value $m1 in regexp compilation at - line 31.
868Use of uninitialized value $g2 in substitution (s///) at - line 31.
869Use of uninitialized value $g2 in substitution (s///) at - line 31.
290797f7
FC
870Use of uninitialized value $g2 in substitution (s///) at - line 32.
871Use of uninitialized value $g1 in substitution (s///) at - line 32.
872Use of uninitialized value $g2 in substitution (s///) at - line 32.
873Use of uninitialized value $g1 in substitution (s///) at - line 32.
874Use of uninitialized value $m1 in regexp compilation at - line 33.
875Use of uninitialized value $g2 in substitution (s///) at - line 33.
876Use of uninitialized value $g2 in substitution (s///) at - line 33.
877Use of uninitialized value $g1 in substitution iterator at - line 33.
878Use of uninitialized value in transliteration (tr///) at - line 34.
879Use of uninitialized value in transliteration (tr///) at - line 35.
29489e7c 880Use of uninitialized value $m1 in regexp compilation at - line 38.
290797f7
FC
881Use of uninitialized value $g1 in regexp compilation at - line 39.
882Use of uninitialized value $m1 in regexp compilation at - line 41.
883Use of uninitialized value $g1 in substitution (s///) at - line 42.
884Use of uninitialized value $m1 in regexp compilation at - line 43.
885Use of uninitialized value $g1 in substitution iterator at - line 43.
886Use of uninitialized value $m1 in substitution iterator at - line 44.
887Use of uninitialized value in substitution iterator at - line 47.
29489e7c
DM
888########
889use warnings 'uninitialized';
890my ($m1);
891
892{ my $foo = "abc"; (substr($foo,0,0)) = ($m1) }
893EXPECT
894Use of uninitialized value $m1 in list assignment at - line 4.
895########
896use warnings 'uninitialized';
897our ($g1);
898
899study;
900study $g1;
901EXPECT
902Use of uninitialized value $_ in study at - line 4.
903Use of uninitialized value $g1 in study at - line 5.
904########
905use warnings 'uninitialized';
906my ($m1);
907
908pos()=0;
909pos($m1)=0;
910EXPECT
911Use of uninitialized value $_ in scalar assignment at - line 4.
912Use of uninitialized value $m1 in scalar assignment at - line 5.
913########
914use warnings 'uninitialized';
915my ($m1);
cc4b8646
DM
916our ($g1);
917
918$v = pos($m1) + 1;
919$v = pos($g1) + 1;
920$m1 = 0;
921$g1 = "";
922$v = pos($m1) + 1;
923$v = pos($g1) + 1;
924EXPECT
925Use of uninitialized value in addition (+) at - line 5.
926Use of uninitialized value in addition (+) at - line 6.
927Use of uninitialized value in addition (+) at - line 9.
928Use of uninitialized value in addition (+) at - line 10.
929########
930use warnings 'uninitialized';
931my ($m1);
29489e7c
DM
932
933{ my $x = "a" x $m1 } # NB LHS of repeat does not warn
934{ my @x = ("a") x $m1 }
935EXPECT
936Use of uninitialized value $m1 in repeat (x) at - line 4.
937Use of uninitialized value $m1 in repeat (x) at - line 5.
938########
939use warnings 'uninitialized';
940my ($m1, $v);
941our ($g1);
942
943$v = "$m1";
944
945$v = $m1 lt $g1;
946$v = $m1 le $g1;
947$v = $m1 gt $g1;
948$v = $m1 ge $g1;
949$v = $m1 eq $g1;
950$v = $m1 ne $g1;
951$v = $m1 cmp $g1;
952EXPECT
953Use of uninitialized value $m1 in string at - line 5.
954Use of uninitialized value $m1 in string lt at - line 7.
955Use of uninitialized value $g1 in string lt at - line 7.
956Use of uninitialized value $m1 in string le at - line 8.
957Use of uninitialized value $g1 in string le at - line 8.
958Use of uninitialized value $m1 in string gt at - line 9.
959Use of uninitialized value $g1 in string gt at - line 9.
960Use of uninitialized value $m1 in string ge at - line 10.
961Use of uninitialized value $g1 in string ge at - line 10.
962Use of uninitialized value $m1 in string eq at - line 11.
963Use of uninitialized value $g1 in string eq at - line 11.
964Use of uninitialized value $m1 in string ne at - line 12.
965Use of uninitialized value $g1 in string ne at - line 12.
966Use of uninitialized value $m1 in string comparison (cmp) at - line 13.
967Use of uninitialized value $g1 in string comparison (cmp) at - line 13.
968########
969use warnings 'uninitialized';
970my ($m1, $v);
971our ($g1);
972
973$v = atan2($m1,$g1);
974$v = sin $m1;
975$v = cos $m1;
976$v = rand $m1;
977$v = srand $m1;
978$v = exp $m1;
979$v = eval {log $m1};
980$v = sqrt $m1;
981$v = hex $m1;
982$v = oct $m1;
9f621bb0
NC
983$v = oct;
984$v = length; # does not warn
29489e7c 985EXPECT
d4b629d0 986Use of uninitialized value $g1 in atan2 at - line 5.
096c060c 987Use of uninitialized value $m1 in atan2 at - line 5.
29489e7c
DM
988Use of uninitialized value $m1 in sin at - line 6.
989Use of uninitialized value $m1 in cos at - line 7.
990Use of uninitialized value $m1 in rand at - line 8.
991Use of uninitialized value $m1 in srand at - line 9.
992Use of uninitialized value $m1 in exp at - line 10.
993Use of uninitialized value $m1 in log at - line 11.
994Use of uninitialized value $m1 in sqrt at - line 12.
995Use of uninitialized value $m1 in hex at - line 13.
996Use of uninitialized value $m1 in oct at - line 14.
9f621bb0 997Use of uninitialized value $_ in oct at - line 15.
29489e7c
DM
998########
999use warnings 'uninitialized';
1000my ($m1, $v);
1001our ($g1);
1002
1003$v = substr $m1, $g1;
1004$v = substr $m1, $g1, $m2;
1005$v = substr $m1, $g1, $m2, $g2; undef $m1;
1006substr($m1, $g1) = $g2; undef $m1; # NB global2
1007substr($m1, $g1, $m2) = $g2; undef $m1; # isn't identified
1008
1009$v = eval {vec ($m1, $g1, $m2)};
1010eval {vec ($m1, $g1, $m2) = $g2}; undef $m1; # ditto
1011
1012$v = index $m1, $m2;
1013$v = index $m1, $m2, $g1;
1014$v = rindex $m1, $m2;
1015$v = rindex $m1, $m2, $g1;
1016EXPECT
1017Use of uninitialized value $g1 in substr at - line 5.
1018Use of uninitialized value $m1 in substr at - line 5.
1019Use of uninitialized value $m2 in substr at - line 6.
1020Use of uninitialized value $g1 in substr at - line 6.
1021Use of uninitialized value $m1 in substr at - line 6.
29489e7c
DM
1022Use of uninitialized value $m2 in substr at - line 7.
1023Use of uninitialized value $g1 in substr at - line 7.
24fcb59f 1024Use of uninitialized value $g2 in substr at - line 7.
29489e7c 1025Use of uninitialized value $m1 in substr at - line 7.
29489e7c 1026Use of uninitialized value $g1 in substr at - line 8.
24fcb59f
FC
1027Use of uninitialized value $g2 in substr at - line 8.
1028Use of uninitialized value $m1 in substr at - line 8.
29489e7c
DM
1029Use of uninitialized value $m2 in substr at - line 9.
1030Use of uninitialized value $g1 in substr at - line 9.
24fcb59f
FC
1031Use of uninitialized value $g2 in substr at - line 9.
1032Use of uninitialized value $m1 in substr at - line 9.
29489e7c
DM
1033Use of uninitialized value $m2 in vec at - line 11.
1034Use of uninitialized value $g1 in vec at - line 11.
1035Use of uninitialized value $m1 in vec at - line 11.
1036Use of uninitialized value $m2 in vec at - line 12.
1037Use of uninitialized value $g1 in vec at - line 12.
29489e7c
DM
1038Use of uninitialized value $m1 in index at - line 14.
1039Use of uninitialized value $m2 in index at - line 14.
1040Use of uninitialized value $g1 in index at - line 15.
1041Use of uninitialized value $m1 in index at - line 15.
1042Use of uninitialized value $m2 in index at - line 15.
29489e7c 1043Use of uninitialized value $m1 in rindex at - line 16.
73ee8be2 1044Use of uninitialized value $m2 in rindex at - line 16.
29489e7c 1045Use of uninitialized value $g1 in rindex at - line 17.
29489e7c 1046Use of uninitialized value $m1 in rindex at - line 17.
73ee8be2 1047Use of uninitialized value $m2 in rindex at - line 17.
29489e7c
DM
1048########
1049use warnings 'uninitialized';
1050my ($m1, $v);
1051our ($g1);
1052
1053$v = sprintf $m1;
1054$v = sprintf '%d%d%d%d', $m1, $m2, $g1, $g2;
094236a2 1055my $m3; eval {formline $m3 };
29489e7c
DM
1056formline '@<<@<<@<<@<<', $m1, $m2, $g1, $g2;
1057EXPECT
1058Use of uninitialized value $m1 in sprintf at - line 5.
1059Use of uninitialized value $m1 in sprintf at - line 6.
1060Use of uninitialized value $m2 in sprintf at - line 6.
1061Use of uninitialized value $g1 in sprintf at - line 6.
1062Use of uninitialized value $g2 in sprintf at - line 6.
094236a2 1063Use of uninitialized value $m3 in formline at - line 7.
29489e7c
DM
1064Use of uninitialized value $m1 in formline at - line 8.
1065Use of uninitialized value $m2 in formline at - line 8.
1066Use of uninitialized value $g1 in formline at - line 8.
1067Use of uninitialized value $g2 in formline at - line 8.
1068########
1069use warnings 'uninitialized';
1070my ($m1, $v);
1071our ($g1);
1072
1073$v = crypt $m1, $g1;
1074
1075$v = ord;
1076$v = ord $m1;
1077$v = chr;
1078$v = chr $m1;
1079
29489e7c
DM
1080$v = ucfirst;
1081$v = ucfirst $m1;
1082$v = lcfirst;
1083$v = lcfirst $m1;
1084$v = uc;
1085$v = uc $m1;
1086$v = lc;
1087$v = lc $m1;
1088
1089$v = quotemeta;
1090$v = quotemeta $m1;
1091EXPECT
1092Use of uninitialized value $m1 in crypt at - line 5.
1093Use of uninitialized value $g1 in crypt at - line 5.
1094Use of uninitialized value $_ in ord at - line 7.
1095Use of uninitialized value $m1 in ord at - line 8.
1096Use of uninitialized value $_ in chr at - line 9.
1097Use of uninitialized value $m1 in chr at - line 10.
0a0ffbce
RGS
1098Use of uninitialized value $_ in ucfirst at - line 12.
1099Use of uninitialized value $m1 in ucfirst at - line 13.
1100Use of uninitialized value $_ in lcfirst at - line 14.
1101Use of uninitialized value $m1 in lcfirst at - line 15.
1102Use of uninitialized value $_ in uc at - line 16.
1103Use of uninitialized value $m1 in uc at - line 17.
1104Use of uninitialized value $_ in lc at - line 18.
1105Use of uninitialized value $m1 in lc at - line 19.
1106Use of uninitialized value $_ in quotemeta at - line 21.
1107Use of uninitialized value $m1 in quotemeta at - line 22.
29489e7c
DM
1108########
1109use warnings 'uninitialized';
1110my ($m1, $v1, $v2, $v3, $v4);
1111our ($g1);
1112
1113($v1,$v2,$v3,$v4) = split;
1114($v1,$v2,$v3,$v4) = split $m1;
1115($v1,$v2,$v3,$v4) = split $m1, $m2;
1116($v1,$v2,$v3,$v4) = split $m1, $m2, $g1;
1117
1118$v1 = join $m1;
1119$v2 = join $m1, $m2;
1120$v3 = join $m1, $m2, $m3;
1121EXPECT
1122Use of uninitialized value $_ in split at - line 5.
1123Use of uninitialized value $m1 in regexp compilation at - line 6.
1124Use of uninitialized value $_ in split at - line 6.
1125Use of uninitialized value $m1 in regexp compilation at - line 7.
1126Use of uninitialized value $m2 in split at - line 7.
1127Use of uninitialized value $m1 in regexp compilation at - line 8.
1128Use of uninitialized value $g1 in split at - line 8.
1129Use of uninitialized value $m2 in split at - line 8.
1130Use of uninitialized value $m1 in join or string at - line 10.
1131Use of uninitialized value $m1 in join or string at - line 11.
1132Use of uninitialized value $m2 in join or string at - line 11.
1133Use of uninitialized value $m1 in join or string at - line 12.
1134Use of uninitialized value $m2 in join or string at - line 12.
1135Use of uninitialized value $m3 in join or string at - line 12.
1136########
1137use warnings 'uninitialized';
1138my ($m1, $m2, @ma, $v);
1139
1140our @foo1=(1,undef); chomp @foo1;
1141my @foo2=(1,undef); chomp @foo2;
1142our @foo3=(1,undef); chop @foo3;
1143my @foo4=(1,undef); chop @foo4;
1144our @foo5=(1,undef); $v = sprintf "%s%s",@foo5;
1145my @foo6=(1,undef); $v = sprintf "%s%s",@foo6;
1146our %foo7=('foo'=>'bar','baz'=>undef); $v = sprintf "%s%s",%foo7;
1147my %foo8=('foo'=>'bar','baz'=>undef); $v = sprintf "%s%s",%foo8;
1148our @foo9 =(1,undef); $v = sprintf "%s%s%s%s",$m1,@foo9, $ma[2];
1149my @foo10=(1,undef); $v = sprintf "%s%s%s%s",$m2,@foo10,$ma[2];
1150our %foo11=('foo'=>'bar','baz'=>undef); $v = join '', %foo11;
1151my %foo12=('foo'=>'bar','baz'=>undef); $v = join '', %foo12;
1152our %foo13=(1..2000,'foo'=>'bar','baz'=>undef); $v = join '', %foo13;
1153my %foo14=(1..2000,'foo'=>'bar','baz'=>undef); $v = join '', %foo14;
1154EXPECT
1155Use of uninitialized value $foo1[1] in chomp at - line 4.
1156Use of uninitialized value $foo2[1] in chomp at - line 5.
1157Use of uninitialized value $foo3[1] in chop at - line 6.
1158Use of uninitialized value $foo4[1] in chop at - line 7.
1159Use of uninitialized value $foo5[1] in sprintf at - line 8.
1160Use of uninitialized value $foo6[1] in sprintf at - line 9.
1161Use of uninitialized value $foo7{"baz"} in sprintf at - line 10.
1162Use of uninitialized value $foo8{"baz"} in sprintf at - line 11.
1163Use of uninitialized value $m1 in sprintf at - line 12.
1164Use of uninitialized value $foo9[1] in sprintf at - line 12.
1165Use of uninitialized value in sprintf at - line 12.
1166Use of uninitialized value $m2 in sprintf at - line 13.
1167Use of uninitialized value $foo10[1] in sprintf at - line 13.
1168Use of uninitialized value in sprintf at - line 13.
1169Use of uninitialized value $foo11{"baz"} in join or string at - line 14.
1170Use of uninitialized value $foo12{"baz"} in join or string at - line 15.
1171Use of uninitialized value within %foo13 in join or string at - line 16.
1172Use of uninitialized value within %foo14 in join or string at - line 17.
1173########
1174use warnings 'uninitialized';
1175my ($v);
1176
1177undef $^A; $v = $^A + ${^FOO}; # should output '^A' not chr(1)
1178*GLOB1 = *GLOB2;
1179$v = $GLOB1 + 1;
1180$v = $GLOB2 + 1;
1181EXPECT
1182Use of uninitialized value $^FOO in addition (+) at - line 4.
1183Use of uninitialized value $^A in addition (+) at - line 4.
1184Use of uninitialized value $GLOB1 in addition (+) at - line 6.
1185Use of uninitialized value $GLOB2 in addition (+) at - line 7.
1186########
1187use warnings 'uninitialized';
1188my ($v);
1189
1190# check hash key is sanitised
d7cf15ed 1191my %h = ("\0011\002\r\n\t\f\"\\\x{1234}abcdefghijklmnopqrstuvwxyz", undef);
29489e7c
DM
1192$v = join '', %h;
1193EXPECT
d7cf15ed 1194Use of uninitialized value $h{"\0011\2\r\n\t\f\"\\\x{1234}abcde"...} in join or string at - line 6.
29489e7c
DM
1195########
1196use warnings 'uninitialized';
1197my ($m1, $v);
1198our ($g1);
1199
1200$v = eval { \&$m1 };
1201$v = eval { \&$g1 };
1202
1203my @a;
1204@a = splice @a, $m1, $g1;
1205$v = 1 + splice @a, $m1, $g1;
1206
1207my $x = bless [], 'Z';
1208eval { $x->$m1() };
1209
1210eval { &$m1() };
1211eval { &$g1() };
1212
1213warn $m1,$g1,"foo";
1214
1215eval { die $m1, $g1 };
1216
1217reset $m1;
1218reset $g1;
1219EXPECT
1220Use of uninitialized value $m1 in subroutine dereference at - line 5.
29489e7c
DM
1221Use of uninitialized value $g1 in subroutine dereference at - line 6.
1222Use of uninitialized value $m1 in splice at - line 9.
1223Use of uninitialized value $g1 in splice at - line 9.
1224Use of uninitialized value $m1 in splice at - line 10.
1225Use of uninitialized value $g1 in splice at - line 10.
1226Use of uninitialized value in addition (+) at - line 10.
1227Use of uninitialized value $m1 in method lookup at - line 13.
7697b7e7
DM
1228Use of uninitialized value in subroutine entry at - line 15.
1229Use of uninitialized value in subroutine entry at - line 16.
29489e7c
DM
1230Use of uninitialized value $m1 in warn at - line 18.
1231Use of uninitialized value $g1 in warn at - line 18.
1232foo at - line 18.
1233Use of uninitialized value $m1 in die at - line 20.
1234Use of uninitialized value $g1 in die at - line 20.
1235Use of uninitialized value $m1 in symbol reset at - line 22.
1236Use of uninitialized value $g1 in symbol reset at - line 23.
1237########
1238use warnings 'uninitialized';
1239my ($m1);
1240our ($g1);
1241
1242open FOO; # accesses $FOO
1243my $foo = 'FO';
1244open($foo."O"); # accesses $FOO
1245open my $x; # accesses ${*$x}
1246open $foobar; # accesses ${*$foobar}
1247my $y;
1248open $y, $m1;
1249eval { open $y, $m1, $g1 };
1250open $y, '<', $g1;
1251
1252sysopen $y, $m1, $m2;
1253sysopen $y, $m1, $g1, $m2;
1254
1255my $old = umask;
1256umask $m1;
1257umask $g1;
1258umask $old;
1259
1260binmode STDIN, $m1;
1261EXPECT
1262Use of uninitialized value $FOO in open at - line 5.
1263Use of uninitialized value in open at - line 7.
1264Use of uninitialized value in open at - line 8.
1265Use of uninitialized value in open at - line 9.
1266Use of uninitialized value $m1 in open at - line 11.
1267Use of uninitialized value $m1 in open at - line 12.
1268Use of uninitialized value $g1 in open at - line 13.
1269Use of uninitialized value $m2 in sysopen at - line 15.
1270Use of uninitialized value $m1 in sysopen at - line 15.
1271Use of uninitialized value $m2 in sysopen at - line 16.
1272Use of uninitialized value $g1 in sysopen at - line 16.
1273Use of uninitialized value $m1 in sysopen at - line 16.
1274Use of uninitialized value $m1 in umask at - line 19.
1275Use of uninitialized value $g1 in umask at - line 20.
1276Use of uninitialized value $m1 in binmode at - line 23.
29489e7c
DM
1277########
1278use warnings 'uninitialized';
1279my ($m1);
1280our ($g1);
1281
1282eval { my $x; tie $x, $m1 };
1283
1284eval { my $x; read $m1, $x, $g1 };
1285eval { my $x; read $m1, $x, $g1, $g2 };
1286eval { my $x; sysread $m1, $x, $g1 };
1287eval { my $x; sysread $m1, $x, $g1, $g2 };
1288EXPECT
1289Use of uninitialized value $m1 in tie at - line 5.
29489e7c
DM
1290Use of uninitialized value $m1 in ref-to-glob cast at - line 7.
1291Use of uninitialized value $g1 in read at - line 7.
1292Use of uninitialized value $m1 in ref-to-glob cast at - line 8.
1293Use of uninitialized value $g1 in read at - line 8.
1294Use of uninitialized value $g2 in read at - line 8.
1295Use of uninitialized value $m1 in ref-to-glob cast at - line 9.
1296Use of uninitialized value $g1 in sysread at - line 9.
1297Use of uninitialized value $m1 in ref-to-glob cast at - line 10.
1298Use of uninitialized value $g1 in sysread at - line 10.
1299Use of uninitialized value $g2 in sysread at - line 10.
1300########
1301use warnings 'uninitialized';
1302my ($m1);
1303our ($g1, @ga);
1304
1305printf $m1;
1306printf STDERR "%d%d%d%d\n", $m1, $m2, $g1, $g2;
1307printf $ga[1000];
1308printf STDERR "FOO1:%s\n", $ga[1000];
1309printf STDERR "FOO2:%s%s%s%s\n", $m1, $g1, $ga[1],$m2;
1310printf STDERR "FOO3:%s%s%s\n", "X", $ga[1],"Y";
1311EXPECT
1312Use of uninitialized value $m1 in printf at - line 5.
1313Use of uninitialized value $m1 in printf at - line 6.
1314Use of uninitialized value $m2 in printf at - line 6.
1315Use of uninitialized value $g1 in printf at - line 6.
1316Use of uninitialized value $g2 in printf at - line 6.
13170000
fa8d1836
DM
1318Use of uninitialized value in printf at - line 7.
1319Use of uninitialized value in printf at - line 8.
29489e7c
DM
1320FOO1:
1321Use of uninitialized value $m1 in printf at - line 9.
1322Use of uninitialized value $g1 in printf at - line 9.
1323Use of uninitialized value in printf at - line 9.
1324Use of uninitialized value $m2 in printf at - line 9.
1325FOO2:
fa8d1836 1326Use of uninitialized value in printf at - line 10.
29489e7c
DM
1327FOO3:XY
1328########
1329use warnings 'uninitialized';
1330my ($m1);
1331our ($g1);
1332
1333eval { my $x; seek $x,$m1, $g1 };
1334eval { my $x; sysseek $x,$m1, $g1 };
c9cb0f41 1335eval { syswrite $m1, $g1 }; # logic changed - now won't try $g1 if $m1 is bad
96d52181
DM
1336# eval { syswrite STDERR, $m1 }; # XXX under utf8, can give
1337# eval { syswrite STDERR, $m1, $g1 }; # XXX different warnings
1338# eval { syswrite STDERR, $m1, $g1, $m2 };
29489e7c
DM
1339eval { my $x; socket $x, $m1, $g1, $m2 };
1340eval { my ($x,$y); socketpair $x, $y, $m1, $g1, $m2 };
1341EXPECT
1342Use of uninitialized value $x in ref-to-glob cast at - line 5.
1343Use of uninitialized value $g1 in seek at - line 5.
1344Use of uninitialized value $m1 in seek at - line 5.
1345Use of uninitialized value $x in ref-to-glob cast at - line 6.
1346Use of uninitialized value $g1 in sysseek at - line 6.
1347Use of uninitialized value $m1 in sysseek at - line 6.
1348Use of uninitialized value $m1 in ref-to-glob cast at - line 7.
c162e49a
CB
1349Use of uninitialized value $m2 in socket at - line 11.
1350Use of uninitialized value $g1 in socket at - line 11.
1351Use of uninitialized value $m1 in socket at - line 11.
1352Use of uninitialized value $m2 in socketpair at - line 12.
1353Use of uninitialized value $g1 in socketpair at - line 12.
1354Use of uninitialized value $m1 in socketpair at - line 12.
1355########
1356use Config;
1357BEGIN {
1358 if ( !$Config{d_flock} &&
1359 !$Config{d_fcntl_can_lock} &&
1360 !$Config{d_lockf} ) {
1361 print <<EOM ;
1362SKIPPED
1363# flock not present
1364EOM
1365 exit ;
1366 }
1367}
1368use warnings 'uninitialized';
1369our ($g1);
1370
1371eval { my $x; flock $x, $g1 };
1372EXPECT
1373Use of uninitialized value $x in ref-to-glob cast at - line 16.
1374Use of uninitialized value $g1 in flock at - line 16.
29489e7c
DM
1375########
1376use warnings 'uninitialized';
1377my ($m1, $v);
1378our ($g1);
1379
1380stat;
1381lstat;
1382stat $m1;
1383lstat $g1;
1384
1385$v = -R $m1;
1386$v = -W $m1;
1387$v = -X $m1;
1388$v = -r $m1;
1389$v = -w $m1;
1390$v = -x $m1;
1391$v = -e $m1;
29489e7c 1392$v = -o $m1;
945fa9b5 1393$v = -O $m1;
29489e7c
DM
1394$v = -z $m1;
1395$v = -s $m1;
1396$v = -M $m1;
1397$v = -A $m1;
1398$v = -C $m1;
1399$v = -S $m1;
1400$v = -c $m1;
1401$v = -b $m1;
1402$v = -f $m1;
1403$v = -d $m1;
1404$v = -p $m1;
1405$v = -l $m1;
1406$v = -u $m1;
1407$v = -g $m1;
96d52181 1408# $v = -k $m1; # XXX this is a no-op under win32
29489e7c
DM
1409$v = -t $m1;
1410$v = -T $m1;
1411$v = -B $m1;
1412EXPECT
1413Use of uninitialized value $_ in stat at - line 5.
1414Use of uninitialized value $_ in lstat at - line 6.
1415Use of uninitialized value $m1 in stat at - line 7.
1416Use of uninitialized value $g1 in lstat at - line 8.
1417Use of uninitialized value $m1 in -R at - line 10.
1418Use of uninitialized value $m1 in -W at - line 11.
1419Use of uninitialized value $m1 in -X at - line 12.
1420Use of uninitialized value $m1 in -r at - line 13.
1421Use of uninitialized value $m1 in -w at - line 14.
1422Use of uninitialized value $m1 in -x at - line 15.
1423Use of uninitialized value $m1 in -e at - line 16.
1424Use of uninitialized value $m1 in -o at - line 17.
1425Use of uninitialized value $m1 in -O at - line 18.
1426Use of uninitialized value $m1 in -z at - line 19.
1427Use of uninitialized value $m1 in -s at - line 20.
1428Use of uninitialized value $m1 in -M at - line 21.
1429Use of uninitialized value $m1 in -A at - line 22.
1430Use of uninitialized value $m1 in -C at - line 23.
1431Use of uninitialized value $m1 in -S at - line 24.
1432Use of uninitialized value $m1 in -c at - line 25.
1433Use of uninitialized value $m1 in -b at - line 26.
1434Use of uninitialized value $m1 in -f at - line 27.
1435Use of uninitialized value $m1 in -d at - line 28.
1436Use of uninitialized value $m1 in -p at - line 29.
1437Use of uninitialized value $m1 in -l at - line 30.
29489e7c
DM
1438Use of uninitialized value $m1 in -u at - line 31.
1439Use of uninitialized value $m1 in -g at - line 32.
29489e7c
DM
1440Use of uninitialized value $m1 in -t at - line 34.
1441Use of uninitialized value $m1 in -T at - line 35.
1442Use of uninitialized value $m1 in -B at - line 36.
1443########
1444use warnings 'uninitialized';
1445my ($m1, $v);
1446our ($g1);
1447
1448$v = localtime $m1;
1449$v = gmtime $g1;
1450EXPECT
1451Use of uninitialized value $m1 in localtime at - line 5.
1452Use of uninitialized value $g1 in gmtime at - line 6.
1453########
1454use warnings 'uninitialized';
50edf520 1455my ($m1, $m2, $v);
29489e7c
DM
1456
1457$v = eval;
1458$v = eval $m1;
50edf520 1459$m2 = q($m1); $v = 1 + eval $m2;
29489e7c
DM
1460EXPECT
1461Use of uninitialized value $_ in eval "string" at - line 4.
29489e7c 1462Use of uninitialized value $m1 in eval "string" at - line 5.
50edf520 1463Use of uninitialized value in addition (+) at - line 6.
29489e7c
DM
1464########
1465use warnings 'uninitialized';
1466my ($m1);
1467
1468exit $m1;
1469EXPECT
1470Use of uninitialized value $m1 in exit at - line 4.
12e06b6f 1471########
12e06b6f
NC
1472use warnings 'uninitialized';
1473my $undef;
1474
1475if ($undef == 3) {
1476} elsif ($undef == 0) {
1477}
1478EXPECT
1479Use of uninitialized value $undef in numeric eq (==) at - line 4.
1480Use of uninitialized value $undef in numeric eq (==) at - line 5.
1481########
79851868
NC
1482# TODO long standing bug - conditions of while loops
1483use warnings;
1484
1485my $c;
1486my $d = 1;
1487while ($c == 0 && $d) {
1488 # a
1489 # few
1490 # blank
1491 # lines
1492 undef $d;
1493}
1494EXPECT
1495Use of uninitialized value $c in numeric eq (==) at - line 5.
1496Use of uninitialized value $c in numeric eq (==) at - line 5.
1497########
d12f7a6a
NC
1498# TODO long standing bug - conditions of until loops
1499use warnings;
1500
1501my $c;
1502my $d;
1503until ($c == 1) {
1504 # a
1505 # few
1506 # blank
1507 # lines
1508 $c = 1 if ++$d == 2;
1509}
1510EXPECT
1511Use of uninitialized value $c in numeric eq (==) at - line 5.
1512Use of uninitialized value $c in numeric eq (==) at - line 5.
1513########
1514# TODO long standing bug - conditions of for loops
1515use warnings;
1516
1517my $c;
1518my $d;
1519for ($d = 1; $c == 0 && $d; ) {
1520 # a
1521 # few
1522 # blank
1523 # lines
1524 undef $d;
1525}
1526
1527my $e;
1528for ($d = 2; $d > 0; $e = !($c == 0)) {
1529 # a
1530 # few
1531 # blank
1532 # lines
1533 --$d;
1534}
1535EXPECT
1536Use of uninitialized value $c in numeric eq (==) at - line 5.
1537Use of uninitialized value $c in numeric eq (==) at - line 5.
1538Use of uninitialized value $c in numeric eq (==) at - line 14.
1539Use of uninitialized value $c in numeric eq (==) at - line 14.
1540########
12e06b6f
NC
1541# TODO long standing bug - more general variant of the above problem
1542use warnings;
1543my $undef;
1544
1545my $a = $undef + 1;
1546my $b
1547 = $undef
1548 + 1;
1549EXPECT
1550Use of uninitialized value $undef in addition (+) at - line 4.
1551Use of uninitialized value $undef in addition (+) at - line 7.
1e21d011
B
1552########
1553use warnings 'uninitialized';
1554my ($r1, $r2);
1555$_ = undef;
1556$v = reverse;
1557$v = reverse $r1;
1558$v = reverse "abc", $r2, "def";
1559EXPECT
1560Use of uninitialized value in reverse at - line 4.
1561Use of uninitialized value $r1 in reverse at - line 5.
1562Use of uninitialized value $r2 in reverse at - line 6.
8b0dea50
DM
1563########
1564use warnings 'uninitialized';
1565#
1566# ops that can return undef for defined args
0b9c91f6 1567# split into separate tests to diagnose the cause of daily build smoke
8b0dea50 1568#
928cb7d4 1569# *** `` not tested: Windows produces an error on STDERR
a3ed38f2 1570# *** ditto qx()
8b0dea50 1571# *** pipe() not tested
8b0dea50
DM
1572# *** ioctl not tested
1573# *** socket not tested
1574# *** socketpair not tested
1575# *** bind not tested
1576# *** connect not tested
1577# *** listen not tested
8b0dea50
DM
1578# *** shutdown not tested
1579# *** setsockopt not tested
1580# *** getpeername not tested
0b9c91f6
NC
1581# *** readdir not tested
1582# *** telldir not tested
1583# *** seekdir not tested
1584# *** rewinddir not tested
1585# *** closedir not tested
1586# *** gmtime not tested
1587# *** alarm not tested
1588# *** semget not tested
1589# *** getlogin not tested
1590EXPECT
1591########
1592use warnings 'uninitialized';
2234743e
NC
1593if ($^O eq 'MSWin32') {
1594 print <<'EOM';
1595SKIPPED
1596# `` produces an error on STDERR on Win32
1597EOM
1598 exit;
1599}
1600my $nocmd = '/no/such/command';
1601my $v;
1602$v = 1 + `$nocmd`;
1603EXPECT
1604Use of uninitialized value in addition (+) at - line 11.
1605########
1606use warnings 'uninitialized';
1607if ($^O eq 'MSWin32') {
1608 print <<'EOM';
1609SKIPPED
1610# qx produces an error on STDERR on Win32
1611EOM
1612 exit;
1613}
1614my $nocmd = '/no/such/command';
1615my $v;
1616$v = 1 + qx($nocmd);
1617EXPECT
1618Use of uninitialized value in addition (+) at - line 11.
1619########
1620use warnings 'uninitialized';
1621my $nan = "NaN";
1622if ($nan == $nan) {
1623 print <<'EOM';
1624SKIPPED
1625# NaN not supported here.
1626EOM
1627 exit;
1628}
1629my $v;
1630$v = 1 + ($nan <=> 1);
1631EXPECT
1632Use of uninitialized value in addition (+) at - line 11.
1633########
1634use warnings 'uninitialized';
1635if ($^O eq 'MSWin32') {
1636 print <<'EOM';
1637SKIPPED
1638# -k produces no warning on Win32
1639EOM
1640 exit;
1641}
1642my $nofile = '/no/such/file';
1643my $v;
1644$v = 1 + -k $nofile;
1645EXPECT
1646Use of uninitialized value in addition (+) at - line 11.
1647########
1648use warnings 'uninitialized';
0b9c91f6
NC
1649my $nofile = '/no/such/file';
1650my $v;
1651my $f = "";
1652$v = 1 + open($f, $nofile);
1653EXPECT
1654Use of uninitialized value in addition (+) at - line 5.
1655########
1656use warnings 'uninitialized';
1657my $nofile = '/no/such/file';
1658my $v;
1659$v = 1 + fileno($nofile);
1660EXPECT
1661Use of uninitialized value in addition (+) at - line 4.
1662########
1663use warnings 'uninitialized';
1664my $nofile = '/no/such/file';
1665my $v;
1666$v = 1 + binmode($nofile);
1667EXPECT
1668Use of uninitialized value in addition (+) at - line 4.
1669########
1670use warnings 'uninitialized';
1671my $nofile = '/no/such/file';
1672my $v;
1673$v = 1 + tied($nofile);
1674EXPECT
1675Use of uninitialized value in addition (+) at - line 4.
1676########
1677use warnings 'uninitialized';
1678my $nofile = '/no/such/file';
1679my $v;
1680$v = 1 + getc($nofile);
1681EXPECT
1682Use of uninitialized value in addition (+) at - line 4.
1683########
1684use warnings 'uninitialized';
1685my $nofile = '/no/such/file';
1686my $v;
1687$v = 1 + sysread($nofile, my $buf,1);
1688EXPECT
1689Use of uninitialized value in addition (+) at - line 4.
1690########
1691use warnings 'uninitialized';
1692my $nofile = '/no/such/file';
1693my $v;
1694$v = 1 + eval { send($nofile, $buf,0) };
1695EXPECT
1696Use of uninitialized value in addition (+) at - line 4.
1697########
1698use warnings 'uninitialized';
1699my $nofile = '/no/such/file';
1700my $v;
1701my $fh = "";
1702$v = 1 + eval { accept($fh, $nofile) };
1703EXPECT
1704Use of uninitialized value in addition (+) at - line 5.
1705########
1706use warnings 'uninitialized';
1707my $nofile = '/no/such/file';
1708my $v;
8b0dea50 1709$v = 1 + (-r $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 + (-w $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 + (-x $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 + (-o $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 + (-R $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 + (-W $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 + (-X $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 + (-O $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 + (-e $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 + (-z $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 + (-f $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 + (-d $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 + (-l $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 + (-p $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 + (-S $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 + (-b $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 + (-c $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 + (-t $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 + (-u $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 + (-g $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 + (-T $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 + (-B $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 + (-M $nofile);
0b9c91f6
NC
1871EXPECT
1872Use of uninitialized value in addition (+) at - line 4.
1873########
1874use warnings 'uninitialized';
1875my $nofile = '/no/such/file';
1876my $v;
8b0dea50 1877$v = 1 + (-A $nofile);
0b9c91f6
NC
1878EXPECT
1879Use of uninitialized value in addition (+) at - line 4.
1880########
1881use warnings 'uninitialized';
1882my $nofile = '/no/such/file';
1883my $v;
8b0dea50 1884$v = 1 + (-C $nofile);
0b9c91f6
NC
1885EXPECT
1886Use of uninitialized value in addition (+) at - line 4.
1887########
1888use warnings 'uninitialized';
1889my $nofile = '/no/such/file';
1890my $v;
8b0dea50 1891$v = 1 + eval { readlink $nofile };
0b9c91f6
NC
1892EXPECT
1893Use of uninitialized value in addition (+) at - line 4.
1894########
1895use warnings 'uninitialized';
1896my $nofile = '/no/such/file';
1897my $v;
8b0dea50 1898$v = 1 + opendir($f, $nofile);
0b9c91f6
NC
1899EXPECT
1900Use of uninitialized value in addition (+) at - line 4.
1901########
1902use warnings 'uninitialized';
1903my $nofile = '/no/such/file';
1904my $v;
8b0dea50 1905$v = 1 + undef;
0b9c91f6
NC
1906EXPECT
1907Use of uninitialized value in addition (+) at - line 4.
1908########
1909use warnings 'uninitialized';
1910my $nofile = '/no/such/file';
1911my $v;
8b0dea50 1912my $x = 1; $v = 1 + undef($x);
0b9c91f6
NC
1913EXPECT
1914Use of uninitialized value in addition (+) at - line 4.
1915########
1916use warnings 'uninitialized';
1917my $v;
8b0dea50
DM
1918my $emptys = "";
1919$v = 1 + substr($emptys,2,1);
0b9c91f6
NC
1920EXPECT
1921Use of uninitialized value in addition (+) at - line 4.
1922########
1923use warnings 'uninitialized';
1924my $v;
8b0dea50
DM
1925my @emptya;
1926$v = 1 + each @emptya;
0b9c91f6
NC
1927EXPECT
1928Use of uninitialized value in addition (+) at - line 4.
1929########
1930use warnings 'uninitialized';
1931my $v;
1932my %emptyh;
8b0dea50 1933$v = 1 + each %emptyh;
0b9c91f6
NC
1934EXPECT
1935Use of uninitialized value in addition (+) at - line 4.
1936########
1937use warnings 'uninitialized';
1938my $v;
1939my @emptya;
8b0dea50 1940$v = 1 + sort @emptya;
0b9c91f6
NC
1941EXPECT
1942Use of uninitialized value in addition (+) at - line 4.
1943########
1944use warnings 'uninitialized';
1945my $v;
8b0dea50 1946my $zero = 0; $v = 1 + caller($zero);
0b9c91f6
NC
1947EXPECT
1948Use of uninitialized value in addition (+) at - line 3.
1949########
1950use warnings 'uninitialized';
1951my $nofile = '/no/such/file';
1952my $v;
8b0dea50 1953$v = 1 + do $nofile;
0b9c91f6
NC
1954EXPECT
1955Use of uninitialized value in addition (+) at - line 4.
1956########
1957use warnings 'uninitialized';
1958my $v;
fa8d1836
DM
1959my $fn = sub {};
1960$v = 1 + prototype $fn;
0b9c91f6
NC
1961EXPECT
1962Use of uninitialized value in addition (+) at - line 4.
1963########
1964use warnings 'uninitialized';
1965my $v;
1966my $fn = sub {};
6ac83b63 1967$v = 1 + (1 ~~ $fn);
0b9c91f6
NC
1968EXPECT
1969Use of uninitialized value in addition (+) at - line 4.
1970########
1971use warnings 'uninitialized';
1972my $v;
1973my $f = "";
fa8d1836 1974$v = 1 + (print STDIN $f); # print to STDIN returns undef
0b9c91f6
NC
1975EXPECT
1976Use of uninitialized value in addition (+) at - line 4.
1977########
1978use warnings 'uninitialized';
1979my $v;
1980my $f = "";
fa8d1836 1981$v = 1 + (printf STDIN "%s", $f);
0b9c91f6
NC
1982EXPECT
1983Use of uninitialized value in addition (+) at - line 4.
1984########
1985use warnings 'uninitialized';
1986my $v;
1987my $f = "";
fa8d1836 1988{ use feature 'say'; $v = 1 + (say STDIN "%s", $f); }
0b9c91f6
NC
1989EXPECT
1990Use of uninitialized value in addition (+) at - line 4.
1991########
1992use warnings 'uninitialized';
1993my $v;
1994my $f = "";
fa8d1836 1995$v = 1 + (unpack("",$f));
0b9c91f6
NC
1996EXPECT
1997Use of uninitialized value in addition (+) at - line 4.
1998########
1999use warnings 'uninitialized';
2000my $nofile = '/no/such/file';
2001my $v;
2002my $f = "";
fa8d1836 2003$v = 1 + sysopen($f, $nofile, 0);
0b9c91f6
NC
2004EXPECT
2005Use of uninitialized value in addition (+) at - line 5.
2006########
2007use warnings 'uninitialized';
2008my $v;
4d6e9c13
GA
2009{ my $x = -1; $v = 1 + sysseek(DATA, $x, 0); }
2010__END__
8b0dea50 2011EXPECT
0b9c91f6 2012Use of uninitialized value in addition (+) at - line 3.
249534c3
FR
2013########
2014use warnings 'uninitialized';
2015delete $::{'Foo::'};
2016my $moo = $Foo::BAR + 42;
2017__END__
2018EXPECT
2019Use of uninitialized value in addition (+) at - line 3.
8f84cc86
FC
2020########
2021use warnings 'uninitialized';
2022use constant {u=>undef, v=>undef};
2023sub foo () {u}
2024sub foo () {v}
2025EXPECT
50de2b3a
FC
2026########
2027# [perl #72090]
2028use warnings 'uninitialized';
2029$a = @$a > 0;
2030EXPECT
2031Use of uninitialized value $a in array dereference at - line 3.
2032Use of uninitialized value in numeric gt (>) at - line 3.
73b42cee
FC
2033########
2034# [perl #103766]
2035use warnings 'uninitialized';
2036"@{[ $x ]}";
2037EXPECT
2038Use of uninitialized value in join or string at - line 3.