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