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