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