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