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