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