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