This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #113576] Restore err msg for &{+undef}
[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.
29489e7c
DM
1228Use of uninitialized value $m1 in warn at - line 18.
1229Use of uninitialized value $g1 in warn at - line 18.
1230foo at - line 18.
1231Use of uninitialized value $m1 in die at - line 20.
1232Use of uninitialized value $g1 in die at - line 20.
1233Use of uninitialized value $m1 in symbol reset at - line 22.
1234Use of uninitialized value $g1 in symbol reset at - line 23.
1235########
1236use warnings 'uninitialized';
1237my ($m1);
1238our ($g1);
1239
1240open FOO; # accesses $FOO
1241my $foo = 'FO';
1242open($foo."O"); # accesses $FOO
1243open my $x; # accesses ${*$x}
1244open $foobar; # accesses ${*$foobar}
1245my $y;
1246open $y, $m1;
1247eval { open $y, $m1, $g1 };
1248open $y, '<', $g1;
1249
1250sysopen $y, $m1, $m2;
1251sysopen $y, $m1, $g1, $m2;
1252
1253my $old = umask;
1254umask $m1;
1255umask $g1;
1256umask $old;
1257
1258binmode STDIN, $m1;
1259EXPECT
1260Use of uninitialized value $FOO in open at - line 5.
1261Use of uninitialized value in open at - line 7.
1262Use of uninitialized value in open at - line 8.
1263Use of uninitialized value in open at - line 9.
1264Use of uninitialized value $m1 in open at - line 11.
1265Use of uninitialized value $m1 in open at - line 12.
1266Use of uninitialized value $g1 in open at - line 13.
1267Use of uninitialized value $m2 in sysopen at - line 15.
1268Use of uninitialized value $m1 in sysopen at - line 15.
1269Use of uninitialized value $m2 in sysopen at - line 16.
1270Use of uninitialized value $g1 in sysopen at - line 16.
1271Use of uninitialized value $m1 in sysopen at - line 16.
1272Use of uninitialized value $m1 in umask at - line 19.
1273Use of uninitialized value $g1 in umask at - line 20.
1274Use of uninitialized value $m1 in binmode at - line 23.
29489e7c
DM
1275########
1276use warnings 'uninitialized';
1277my ($m1);
1278our ($g1);
1279
1280eval { my $x; tie $x, $m1 };
1281
1282eval { my $x; read $m1, $x, $g1 };
1283eval { my $x; read $m1, $x, $g1, $g2 };
1284eval { my $x; sysread $m1, $x, $g1 };
1285eval { my $x; sysread $m1, $x, $g1, $g2 };
1286EXPECT
1287Use of uninitialized value $m1 in tie at - line 5.
29489e7c
DM
1288Use of uninitialized value $m1 in ref-to-glob cast at - line 7.
1289Use of uninitialized value $g1 in read at - line 7.
1290Use of uninitialized value $m1 in ref-to-glob cast at - line 8.
1291Use of uninitialized value $g1 in read at - line 8.
1292Use of uninitialized value $g2 in read at - line 8.
1293Use of uninitialized value $m1 in ref-to-glob cast at - line 9.
1294Use of uninitialized value $g1 in sysread at - line 9.
1295Use of uninitialized value $m1 in ref-to-glob cast at - line 10.
1296Use of uninitialized value $g1 in sysread at - line 10.
1297Use of uninitialized value $g2 in sysread at - line 10.
1298########
1299use warnings 'uninitialized';
1300my ($m1);
1301our ($g1, @ga);
1302
1303printf $m1;
1304printf STDERR "%d%d%d%d\n", $m1, $m2, $g1, $g2;
1305printf $ga[1000];
1306printf STDERR "FOO1:%s\n", $ga[1000];
1307printf STDERR "FOO2:%s%s%s%s\n", $m1, $g1, $ga[1],$m2;
1308printf STDERR "FOO3:%s%s%s\n", "X", $ga[1],"Y";
1309EXPECT
1310Use of uninitialized value $m1 in printf at - line 5.
1311Use of uninitialized value $m1 in printf at - line 6.
1312Use of uninitialized value $m2 in printf at - line 6.
1313Use of uninitialized value $g1 in printf at - line 6.
1314Use of uninitialized value $g2 in printf at - line 6.
13150000
fa8d1836
DM
1316Use of uninitialized value in printf at - line 7.
1317Use of uninitialized value in printf at - line 8.
29489e7c
DM
1318FOO1:
1319Use of uninitialized value $m1 in printf at - line 9.
1320Use of uninitialized value $g1 in printf at - line 9.
1321Use of uninitialized value in printf at - line 9.
1322Use of uninitialized value $m2 in printf at - line 9.
1323FOO2:
fa8d1836 1324Use of uninitialized value in printf at - line 10.
29489e7c
DM
1325FOO3:XY
1326########
1327use warnings 'uninitialized';
1328my ($m1);
1329our ($g1);
1330
1331eval { my $x; seek $x,$m1, $g1 };
1332eval { my $x; sysseek $x,$m1, $g1 };
c9cb0f41 1333eval { syswrite $m1, $g1 }; # logic changed - now won't try $g1 if $m1 is bad
96d52181
DM
1334# eval { syswrite STDERR, $m1 }; # XXX under utf8, can give
1335# eval { syswrite STDERR, $m1, $g1 }; # XXX different warnings
1336# eval { syswrite STDERR, $m1, $g1, $m2 };
29489e7c
DM
1337eval { my $x; socket $x, $m1, $g1, $m2 };
1338eval { my ($x,$y); socketpair $x, $y, $m1, $g1, $m2 };
1339EXPECT
1340Use of uninitialized value $x in ref-to-glob cast at - line 5.
1341Use of uninitialized value $g1 in seek at - line 5.
1342Use of uninitialized value $m1 in seek at - line 5.
1343Use of uninitialized value $x in ref-to-glob cast at - line 6.
1344Use of uninitialized value $g1 in sysseek at - line 6.
1345Use of uninitialized value $m1 in sysseek at - line 6.
1346Use of uninitialized value $m1 in ref-to-glob cast at - line 7.
c162e49a
CB
1347Use of uninitialized value $m2 in socket at - line 11.
1348Use of uninitialized value $g1 in socket at - line 11.
1349Use of uninitialized value $m1 in socket at - line 11.
1350Use of uninitialized value $m2 in socketpair at - line 12.
1351Use of uninitialized value $g1 in socketpair at - line 12.
1352Use of uninitialized value $m1 in socketpair at - line 12.
1353########
1354use Config;
1355BEGIN {
1356 if ( !$Config{d_flock} &&
1357 !$Config{d_fcntl_can_lock} &&
1358 !$Config{d_lockf} ) {
1359 print <<EOM ;
1360SKIPPED
1361# flock not present
1362EOM
1363 exit ;
1364 }
1365}
1366use warnings 'uninitialized';
1367our ($g1);
1368
1369eval { my $x; flock $x, $g1 };
1370EXPECT
1371Use of uninitialized value $x in ref-to-glob cast at - line 16.
1372Use of uninitialized value $g1 in flock at - line 16.
29489e7c
DM
1373########
1374use warnings 'uninitialized';
1375my ($m1, $v);
1376our ($g1);
1377
1378stat;
1379lstat;
1380stat $m1;
1381lstat $g1;
1382
1383$v = -R $m1;
1384$v = -W $m1;
1385$v = -X $m1;
1386$v = -r $m1;
1387$v = -w $m1;
1388$v = -x $m1;
1389$v = -e $m1;
29489e7c 1390$v = -o $m1;
945fa9b5 1391$v = -O $m1;
29489e7c
DM
1392$v = -z $m1;
1393$v = -s $m1;
1394$v = -M $m1;
1395$v = -A $m1;
1396$v = -C $m1;
1397$v = -S $m1;
1398$v = -c $m1;
1399$v = -b $m1;
1400$v = -f $m1;
1401$v = -d $m1;
1402$v = -p $m1;
1403$v = -l $m1;
1404$v = -u $m1;
1405$v = -g $m1;
96d52181 1406# $v = -k $m1; # XXX this is a no-op under win32
29489e7c
DM
1407$v = -t $m1;
1408$v = -T $m1;
1409$v = -B $m1;
1410EXPECT
1411Use of uninitialized value $_ in stat at - line 5.
1412Use of uninitialized value $_ in lstat at - line 6.
1413Use of uninitialized value $m1 in stat at - line 7.
1414Use of uninitialized value $g1 in lstat at - line 8.
1415Use of uninitialized value $m1 in -R at - line 10.
1416Use of uninitialized value $m1 in -W at - line 11.
1417Use of uninitialized value $m1 in -X at - line 12.
1418Use of uninitialized value $m1 in -r at - line 13.
1419Use of uninitialized value $m1 in -w at - line 14.
1420Use of uninitialized value $m1 in -x at - line 15.
1421Use of uninitialized value $m1 in -e at - line 16.
1422Use of uninitialized value $m1 in -o at - line 17.
1423Use of uninitialized value $m1 in -O at - line 18.
1424Use of uninitialized value $m1 in -z at - line 19.
1425Use of uninitialized value $m1 in -s at - line 20.
1426Use of uninitialized value $m1 in -M at - line 21.
1427Use of uninitialized value $m1 in -A at - line 22.
1428Use of uninitialized value $m1 in -C at - line 23.
1429Use of uninitialized value $m1 in -S at - line 24.
1430Use of uninitialized value $m1 in -c at - line 25.
1431Use of uninitialized value $m1 in -b at - line 26.
1432Use of uninitialized value $m1 in -f at - line 27.
1433Use of uninitialized value $m1 in -d at - line 28.
1434Use of uninitialized value $m1 in -p at - line 29.
1435Use of uninitialized value $m1 in -l at - line 30.
29489e7c
DM
1436Use of uninitialized value $m1 in -u at - line 31.
1437Use of uninitialized value $m1 in -g at - line 32.
29489e7c
DM
1438Use of uninitialized value $m1 in -t at - line 34.
1439Use of uninitialized value $m1 in -T at - line 35.
1440Use of uninitialized value $m1 in -B at - line 36.
1441########
1442use warnings 'uninitialized';
1443my ($m1, $v);
1444our ($g1);
1445
1446$v = localtime $m1;
1447$v = gmtime $g1;
1448EXPECT
1449Use of uninitialized value $m1 in localtime at - line 5.
1450Use of uninitialized value $g1 in gmtime at - line 6.
1451########
1452use warnings 'uninitialized';
50edf520 1453my ($m1, $m2, $v);
29489e7c
DM
1454
1455$v = eval;
1456$v = eval $m1;
50edf520 1457$m2 = q($m1); $v = 1 + eval $m2;
29489e7c
DM
1458EXPECT
1459Use of uninitialized value $_ in eval "string" at - line 4.
29489e7c 1460Use of uninitialized value $m1 in eval "string" at - line 5.
50edf520 1461Use of uninitialized value in addition (+) at - line 6.
29489e7c
DM
1462########
1463use warnings 'uninitialized';
1464my ($m1);
1465
1466exit $m1;
1467EXPECT
1468Use of uninitialized value $m1 in exit at - line 4.
12e06b6f 1469########
12e06b6f
NC
1470use warnings 'uninitialized';
1471my $undef;
1472
1473if ($undef == 3) {
1474} elsif ($undef == 0) {
1475}
1476EXPECT
1477Use of uninitialized value $undef in numeric eq (==) at - line 4.
1478Use of uninitialized value $undef in numeric eq (==) at - line 5.
1479########
79851868
NC
1480# TODO long standing bug - conditions of while loops
1481use warnings;
1482
1483my $c;
1484my $d = 1;
1485while ($c == 0 && $d) {
1486 # a
1487 # few
1488 # blank
1489 # lines
1490 undef $d;
1491}
1492EXPECT
1493Use of uninitialized value $c in numeric eq (==) at - line 5.
1494Use of uninitialized value $c in numeric eq (==) at - line 5.
1495########
d12f7a6a
NC
1496# TODO long standing bug - conditions of until loops
1497use warnings;
1498
1499my $c;
1500my $d;
1501until ($c == 1) {
1502 # a
1503 # few
1504 # blank
1505 # lines
1506 $c = 1 if ++$d == 2;
1507}
1508EXPECT
1509Use of uninitialized value $c in numeric eq (==) at - line 5.
1510Use of uninitialized value $c in numeric eq (==) at - line 5.
1511########
1512# TODO long standing bug - conditions of for loops
1513use warnings;
1514
1515my $c;
1516my $d;
1517for ($d = 1; $c == 0 && $d; ) {
1518 # a
1519 # few
1520 # blank
1521 # lines
1522 undef $d;
1523}
1524
1525my $e;
1526for ($d = 2; $d > 0; $e = !($c == 0)) {
1527 # a
1528 # few
1529 # blank
1530 # lines
1531 --$d;
1532}
1533EXPECT
1534Use of uninitialized value $c in numeric eq (==) at - line 5.
1535Use of uninitialized value $c in numeric eq (==) at - line 5.
1536Use of uninitialized value $c in numeric eq (==) at - line 14.
1537Use of uninitialized value $c in numeric eq (==) at - line 14.
1538########
12e06b6f
NC
1539# TODO long standing bug - more general variant of the above problem
1540use warnings;
1541my $undef;
1542
1543my $a = $undef + 1;
1544my $b
1545 = $undef
1546 + 1;
1547EXPECT
1548Use of uninitialized value $undef in addition (+) at - line 4.
1549Use of uninitialized value $undef in addition (+) at - line 7.
1e21d011
B
1550########
1551use warnings 'uninitialized';
1552my ($r1, $r2);
1553$_ = undef;
1554$v = reverse;
1555$v = reverse $r1;
1556$v = reverse "abc", $r2, "def";
1557EXPECT
1558Use of uninitialized value in reverse at - line 4.
1559Use of uninitialized value $r1 in reverse at - line 5.
1560Use of uninitialized value $r2 in reverse at - line 6.
8b0dea50
DM
1561########
1562use warnings 'uninitialized';
1563#
1564# ops that can return undef for defined args
0b9c91f6 1565# split into separate tests to diagnose the cause of daily build smoke
8b0dea50 1566#
928cb7d4 1567# *** `` not tested: Windows produces an error on STDERR
a3ed38f2 1568# *** ditto qx()
8b0dea50 1569# *** pipe() not tested
8b0dea50
DM
1570# *** ioctl not tested
1571# *** socket not tested
1572# *** socketpair not tested
1573# *** bind not tested
1574# *** connect not tested
1575# *** listen not tested
8b0dea50
DM
1576# *** shutdown not tested
1577# *** setsockopt not tested
1578# *** getpeername not tested
0b9c91f6
NC
1579# *** readdir not tested
1580# *** telldir not tested
1581# *** seekdir not tested
1582# *** rewinddir not tested
1583# *** closedir not tested
1584# *** gmtime not tested
1585# *** alarm not tested
1586# *** semget not tested
1587# *** getlogin not tested
1588EXPECT
1589########
1590use warnings 'uninitialized';
2234743e
NC
1591if ($^O eq 'MSWin32') {
1592 print <<'EOM';
1593SKIPPED
1594# `` produces an error on STDERR on Win32
1595EOM
1596 exit;
1597}
1598my $nocmd = '/no/such/command';
1599my $v;
1600$v = 1 + `$nocmd`;
1601EXPECT
1602Use of uninitialized value in addition (+) at - line 11.
1603########
1604use warnings 'uninitialized';
1605if ($^O eq 'MSWin32') {
1606 print <<'EOM';
1607SKIPPED
1608# qx produces an error on STDERR on Win32
1609EOM
1610 exit;
1611}
1612my $nocmd = '/no/such/command';
1613my $v;
1614$v = 1 + qx($nocmd);
1615EXPECT
1616Use of uninitialized value in addition (+) at - line 11.
1617########
1618use warnings 'uninitialized';
1619my $nan = "NaN";
1620if ($nan == $nan) {
1621 print <<'EOM';
1622SKIPPED
1623# NaN not supported here.
1624EOM
1625 exit;
1626}
1627my $v;
1628$v = 1 + ($nan <=> 1);
1629EXPECT
1630Use of uninitialized value in addition (+) at - line 11.
1631########
1632use warnings 'uninitialized';
1633if ($^O eq 'MSWin32') {
1634 print <<'EOM';
1635SKIPPED
1636# -k produces no warning on Win32
1637EOM
1638 exit;
1639}
1640my $nofile = '/no/such/file';
1641my $v;
1642$v = 1 + -k $nofile;
1643EXPECT
1644Use of uninitialized value in addition (+) at - line 11.
1645########
1646use warnings 'uninitialized';
0b9c91f6
NC
1647my $nofile = '/no/such/file';
1648my $v;
1649my $f = "";
1650$v = 1 + open($f, $nofile);
1651EXPECT
1652Use of uninitialized value in addition (+) at - line 5.
1653########
1654use warnings 'uninitialized';
1655my $nofile = '/no/such/file';
1656my $v;
1657$v = 1 + fileno($nofile);
1658EXPECT
1659Use of uninitialized value in addition (+) at - line 4.
1660########
1661use warnings 'uninitialized';
1662my $nofile = '/no/such/file';
1663my $v;
1664$v = 1 + binmode($nofile);
1665EXPECT
1666Use of uninitialized value in addition (+) at - line 4.
1667########
1668use warnings 'uninitialized';
1669my $nofile = '/no/such/file';
1670my $v;
1671$v = 1 + tied($nofile);
1672EXPECT
1673Use of uninitialized value in addition (+) at - line 4.
1674########
1675use warnings 'uninitialized';
1676my $nofile = '/no/such/file';
1677my $v;
1678$v = 1 + getc($nofile);
1679EXPECT
1680Use of uninitialized value in addition (+) at - line 4.
1681########
1682use warnings 'uninitialized';
1683my $nofile = '/no/such/file';
1684my $v;
1685$v = 1 + sysread($nofile, my $buf,1);
1686EXPECT
1687Use of uninitialized value in addition (+) at - line 4.
1688########
1689use warnings 'uninitialized';
1690my $nofile = '/no/such/file';
1691my $v;
1692$v = 1 + eval { send($nofile, $buf,0) };
1693EXPECT
1694Use of uninitialized value in addition (+) at - line 4.
1695########
1696use warnings 'uninitialized';
1697my $nofile = '/no/such/file';
1698my $v;
1699my $fh = "";
1700$v = 1 + eval { accept($fh, $nofile) };
1701EXPECT
1702Use of uninitialized value in addition (+) at - line 5.
1703########
1704use warnings 'uninitialized';
1705my $nofile = '/no/such/file';
1706my $v;
8b0dea50 1707$v = 1 + (-r $nofile);
0b9c91f6
NC
1708EXPECT
1709Use of uninitialized value in addition (+) at - line 4.
1710########
1711use warnings 'uninitialized';
1712my $nofile = '/no/such/file';
1713my $v;
8b0dea50 1714$v = 1 + (-w $nofile);
0b9c91f6
NC
1715EXPECT
1716Use of uninitialized value in addition (+) at - line 4.
1717########
1718use warnings 'uninitialized';
1719my $nofile = '/no/such/file';
1720my $v;
8b0dea50 1721$v = 1 + (-x $nofile);
0b9c91f6
NC
1722EXPECT
1723Use of uninitialized value in addition (+) at - line 4.
1724########
1725use warnings 'uninitialized';
1726my $nofile = '/no/such/file';
1727my $v;
8b0dea50 1728$v = 1 + (-o $nofile);
0b9c91f6
NC
1729EXPECT
1730Use of uninitialized value in addition (+) at - line 4.
1731########
1732use warnings 'uninitialized';
1733my $nofile = '/no/such/file';
1734my $v;
8b0dea50 1735$v = 1 + (-R $nofile);
0b9c91f6
NC
1736EXPECT
1737Use of uninitialized value in addition (+) at - line 4.
1738########
1739use warnings 'uninitialized';
1740my $nofile = '/no/such/file';
1741my $v;
8b0dea50 1742$v = 1 + (-W $nofile);
0b9c91f6
NC
1743EXPECT
1744Use of uninitialized value in addition (+) at - line 4.
1745########
1746use warnings 'uninitialized';
1747my $nofile = '/no/such/file';
1748my $v;
8b0dea50 1749$v = 1 + (-X $nofile);
0b9c91f6
NC
1750EXPECT
1751Use of uninitialized value in addition (+) at - line 4.
1752########
1753use warnings 'uninitialized';
1754my $nofile = '/no/such/file';
1755my $v;
8b0dea50 1756$v = 1 + (-O $nofile);
0b9c91f6
NC
1757EXPECT
1758Use of uninitialized value in addition (+) at - line 4.
1759########
1760use warnings 'uninitialized';
1761my $nofile = '/no/such/file';
1762my $v;
8b0dea50 1763$v = 1 + (-e $nofile);
0b9c91f6
NC
1764EXPECT
1765Use of uninitialized value in addition (+) at - line 4.
1766########
1767use warnings 'uninitialized';
1768my $nofile = '/no/such/file';
1769my $v;
8b0dea50 1770$v = 1 + (-z $nofile);
0b9c91f6
NC
1771EXPECT
1772Use of uninitialized value in addition (+) at - line 4.
1773########
1774use warnings 'uninitialized';
1775my $nofile = '/no/such/file';
1776my $v;
8b0dea50 1777$v = 1 + (-s $nofile);
0b9c91f6
NC
1778EXPECT
1779Use of uninitialized value in addition (+) at - line 4.
1780########
1781use warnings 'uninitialized';
1782my $nofile = '/no/such/file';
1783my $v;
8b0dea50 1784$v = 1 + (-f $nofile);
0b9c91f6
NC
1785EXPECT
1786Use of uninitialized value in addition (+) at - line 4.
1787########
1788use warnings 'uninitialized';
1789my $nofile = '/no/such/file';
1790my $v;
8b0dea50 1791$v = 1 + (-d $nofile);
0b9c91f6
NC
1792EXPECT
1793Use of uninitialized value in addition (+) at - line 4.
1794########
1795use warnings 'uninitialized';
1796my $nofile = '/no/such/file';
1797my $v;
8b0dea50 1798$v = 1 + (-l $nofile);
0b9c91f6
NC
1799EXPECT
1800Use of uninitialized value in addition (+) at - line 4.
1801########
1802use warnings 'uninitialized';
1803my $nofile = '/no/such/file';
1804my $v;
8b0dea50 1805$v = 1 + (-p $nofile);
0b9c91f6
NC
1806EXPECT
1807Use of uninitialized value in addition (+) at - line 4.
1808########
1809use warnings 'uninitialized';
1810my $nofile = '/no/such/file';
1811my $v;
8b0dea50 1812$v = 1 + (-S $nofile);
0b9c91f6
NC
1813EXPECT
1814Use of uninitialized value in addition (+) at - line 4.
1815########
1816use warnings 'uninitialized';
1817my $nofile = '/no/such/file';
1818my $v;
8b0dea50 1819$v = 1 + (-b $nofile);
0b9c91f6
NC
1820EXPECT
1821Use of uninitialized value in addition (+) at - line 4.
1822########
1823use warnings 'uninitialized';
1824my $nofile = '/no/such/file';
1825my $v;
8b0dea50 1826$v = 1 + (-c $nofile);
0b9c91f6
NC
1827EXPECT
1828Use of uninitialized value in addition (+) at - line 4.
1829########
1830use warnings 'uninitialized';
1831my $nofile = '/no/such/file';
1832my $v;
8b0dea50 1833$v = 1 + (-t $nofile);
0b9c91f6
NC
1834EXPECT
1835Use of uninitialized value in addition (+) at - line 4.
1836########
1837use warnings 'uninitialized';
1838my $nofile = '/no/such/file';
1839my $v;
8b0dea50 1840$v = 1 + (-u $nofile);
0b9c91f6
NC
1841EXPECT
1842Use of uninitialized value in addition (+) at - line 4.
1843########
1844use warnings 'uninitialized';
1845my $nofile = '/no/such/file';
1846my $v;
8b0dea50 1847$v = 1 + (-g $nofile);
0b9c91f6
NC
1848EXPECT
1849Use of uninitialized value in addition (+) at - line 4.
1850########
1851use warnings 'uninitialized';
1852my $nofile = '/no/such/file';
1853my $v;
8b0dea50 1854$v = 1 + (-T $nofile);
0b9c91f6
NC
1855EXPECT
1856Use of uninitialized value in addition (+) at - line 4.
1857########
1858use warnings 'uninitialized';
1859my $nofile = '/no/such/file';
1860my $v;
8b0dea50 1861$v = 1 + (-B $nofile);
0b9c91f6
NC
1862EXPECT
1863Use of uninitialized value in addition (+) at - line 4.
1864########
1865use warnings 'uninitialized';
1866my $nofile = '/no/such/file';
1867my $v;
8b0dea50 1868$v = 1 + (-M $nofile);
0b9c91f6
NC
1869EXPECT
1870Use of uninitialized value in addition (+) at - line 4.
1871########
1872use warnings 'uninitialized';
1873my $nofile = '/no/such/file';
1874my $v;
8b0dea50 1875$v = 1 + (-A $nofile);
0b9c91f6
NC
1876EXPECT
1877Use of uninitialized value in addition (+) at - line 4.
1878########
1879use warnings 'uninitialized';
1880my $nofile = '/no/such/file';
1881my $v;
8b0dea50 1882$v = 1 + (-C $nofile);
0b9c91f6
NC
1883EXPECT
1884Use of uninitialized value in addition (+) at - line 4.
1885########
1886use warnings 'uninitialized';
1887my $nofile = '/no/such/file';
1888my $v;
8b0dea50 1889$v = 1 + eval { readlink $nofile };
0b9c91f6
NC
1890EXPECT
1891Use of uninitialized value in addition (+) at - line 4.
1892########
1893use warnings 'uninitialized';
1894my $nofile = '/no/such/file';
1895my $v;
8b0dea50 1896$v = 1 + opendir($f, $nofile);
0b9c91f6
NC
1897EXPECT
1898Use of uninitialized value in addition (+) at - line 4.
1899########
1900use warnings 'uninitialized';
1901my $nofile = '/no/such/file';
1902my $v;
8b0dea50 1903$v = 1 + undef;
0b9c91f6
NC
1904EXPECT
1905Use of uninitialized value in addition (+) at - line 4.
1906########
1907use warnings 'uninitialized';
1908my $nofile = '/no/such/file';
1909my $v;
8b0dea50 1910my $x = 1; $v = 1 + undef($x);
0b9c91f6
NC
1911EXPECT
1912Use of uninitialized value in addition (+) at - line 4.
1913########
1914use warnings 'uninitialized';
1915my $v;
8b0dea50
DM
1916my $emptys = "";
1917$v = 1 + substr($emptys,2,1);
0b9c91f6
NC
1918EXPECT
1919Use of uninitialized value in addition (+) at - line 4.
1920########
1921use warnings 'uninitialized';
1922my $v;
8b0dea50
DM
1923my @emptya;
1924$v = 1 + each @emptya;
0b9c91f6
NC
1925EXPECT
1926Use of uninitialized value in addition (+) at - line 4.
1927########
1928use warnings 'uninitialized';
1929my $v;
1930my %emptyh;
8b0dea50 1931$v = 1 + each %emptyh;
0b9c91f6
NC
1932EXPECT
1933Use of uninitialized value in addition (+) at - line 4.
1934########
1935use warnings 'uninitialized';
1936my $v;
1937my @emptya;
8b0dea50 1938$v = 1 + sort @emptya;
0b9c91f6
NC
1939EXPECT
1940Use of uninitialized value in addition (+) at - line 4.
1941########
1942use warnings 'uninitialized';
1943my $v;
8b0dea50 1944my $zero = 0; $v = 1 + caller($zero);
0b9c91f6
NC
1945EXPECT
1946Use of uninitialized value in addition (+) at - line 3.
1947########
1948use warnings 'uninitialized';
1949my $nofile = '/no/such/file';
1950my $v;
8b0dea50 1951$v = 1 + do $nofile;
0b9c91f6
NC
1952EXPECT
1953Use of uninitialized value in addition (+) at - line 4.
1954########
1955use warnings 'uninitialized';
1956my $v;
fa8d1836
DM
1957my $fn = sub {};
1958$v = 1 + prototype $fn;
0b9c91f6
NC
1959EXPECT
1960Use of uninitialized value in addition (+) at - line 4.
1961########
1962use warnings 'uninitialized';
1963my $v;
1964my $fn = sub {};
6ac83b63 1965$v = 1 + (1 ~~ $fn);
0b9c91f6
NC
1966EXPECT
1967Use of uninitialized value in addition (+) at - line 4.
1968########
1969use warnings 'uninitialized';
1970my $v;
1971my $f = "";
fa8d1836 1972$v = 1 + (print STDIN $f); # print to STDIN returns undef
0b9c91f6
NC
1973EXPECT
1974Use of uninitialized value in addition (+) at - line 4.
1975########
1976use warnings 'uninitialized';
1977my $v;
1978my $f = "";
fa8d1836 1979$v = 1 + (printf STDIN "%s", $f);
0b9c91f6
NC
1980EXPECT
1981Use of uninitialized value in addition (+) at - line 4.
1982########
1983use warnings 'uninitialized';
1984my $v;
1985my $f = "";
fa8d1836 1986{ use feature 'say'; $v = 1 + (say STDIN "%s", $f); }
0b9c91f6
NC
1987EXPECT
1988Use of uninitialized value in addition (+) at - line 4.
1989########
1990use warnings 'uninitialized';
1991my $v;
1992my $f = "";
fa8d1836 1993$v = 1 + (unpack("",$f));
0b9c91f6
NC
1994EXPECT
1995Use of uninitialized value in addition (+) at - line 4.
1996########
1997use warnings 'uninitialized';
1998my $nofile = '/no/such/file';
1999my $v;
2000my $f = "";
fa8d1836 2001$v = 1 + sysopen($f, $nofile, 0);
0b9c91f6
NC
2002EXPECT
2003Use of uninitialized value in addition (+) at - line 5.
2004########
2005use warnings 'uninitialized';
2006my $v;
4d6e9c13
GA
2007{ my $x = -1; $v = 1 + sysseek(DATA, $x, 0); }
2008__END__
8b0dea50 2009EXPECT
0b9c91f6 2010Use of uninitialized value in addition (+) at - line 3.
249534c3
FR
2011########
2012use warnings 'uninitialized';
2013delete $::{'Foo::'};
2014my $moo = $Foo::BAR + 42;
2015__END__
2016EXPECT
2017Use of uninitialized value in addition (+) at - line 3.
8f84cc86
FC
2018########
2019use warnings 'uninitialized';
2020use constant {u=>undef, v=>undef};
2021sub foo () {u}
2022sub foo () {v}
2023EXPECT
50de2b3a
FC
2024########
2025# [perl #72090]
2026use warnings 'uninitialized';
2027$a = @$a > 0;
2028EXPECT
2029Use of uninitialized value $a in array dereference at - line 3.
2030Use of uninitialized value in numeric gt (>) at - line 3.
73b42cee
FC
2031########
2032# [perl #103766]
2033use warnings 'uninitialized';
2034"@{[ $x ]}";
2035EXPECT
2036Use of uninitialized value in join or string at - line 3.