This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Include variable names in "Use of uninitialized value" warnings
[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
285Use of uninitialized value $ga[1000] in print at - line 5.
286Use of uninitialized value $ga[1000] in print at - line 6.
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.
291Use of uninitialized value $ga[1] in print at - line 8.
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;
314EXPECT
315Use of uninitialized value $m1 in scalar dereference at - line 5.
316Use of uninitialized value $g1 in scalar dereference at - line 6.
317Use of uninitialized value $m1 in array dereference at - line 8.
318Use of uninitialized value $g1 in array dereference at - line 9.
319Use of uninitialized value $m2 in hash dereference at - line 10.
320Use of uninitialized value $g2 in hash dereference at - line 11.
321########
322use warnings 'uninitialized';
323my ($m1, $v);
324our ($g1);
325
326$v = $m1 | $m2;
327$v = $m1 & $m2;
328$v = $m1 ^ $m2;
329$v = ~$m1;
330
331$v = $g1 | $g2;
332$v = $g1 & $g2;
333$v = $g1 ^ $g2;
334$v = ~$g1;
335EXPECT
336Use of uninitialized value $m1 in bitwise or (|) at - line 5.
337Use of uninitialized value $m2 in bitwise or (|) at - line 5.
338Use of uninitialized value $m1 in bitwise and (&) at - line 6.
339Use of uninitialized value $m2 in bitwise and (&) at - line 6.
340Use of uninitialized value $m1 in bitwise xor (^) at - line 7.
341Use of uninitialized value $m2 in bitwise xor (^) at - line 7.
342Use of uninitialized value $m1 in 1's complement (~) at - line 8.
343Use of uninitialized value $g1 in bitwise or (|) at - line 10.
344Use of uninitialized value $g2 in bitwise or (|) at - line 10.
345Use of uninitialized value $g1 in bitwise and (&) at - line 11.
346Use of uninitialized value $g2 in bitwise and (&) at - line 11.
347Use of uninitialized value $g1 in bitwise xor (^) at - line 12.
348Use of uninitialized value $g2 in bitwise xor (^) at - line 12.
349Use of uninitialized value $g1 in 1's complement (~) at - line 13.
350########
351use warnings 'uninitialized';
352my ($v);
353
354my $tmp1; $v = $tmp1++; # (doesn't warn)
355our $tmp2; $v = $tmp2++; # (doesn't warn)
356my $tmp3; $v = ++$tmp1; # (doesn't warn)
357our $tmp4; $v = ++$tmp2; # (doesn't warn)
358
359my $tmp5; $v = $tmp5--; # (doesn't warn)
360our $tmp6; $v = $tmp6--; # (doesn't warn)
361my $tmp7; $v = --$tmp7; # (doesn't warn)
362our $tmp8; $v = --$tmp8; # (doesn't warn)
363EXPECT
364########
365use warnings 'uninitialized';
366
367my $s1; chomp $s1;
368my $s2; chop $s2;
369my ($s3,$s4); chomp ($s3,$s4);
370my ($s5,$s6); chop ($s5,$s6);
371EXPECT
372Use of uninitialized value $s1 in scalar chomp at - line 3.
373Use of uninitialized value $s2 in scalar chop at - line 4.
374Use of uninitialized value $s4 in chomp at - line 5.
375Use of uninitialized value $s3 in chomp at - line 5.
376Use of uninitialized value $s5 in chop at - line 6.
377Use of uninitialized value $s6 in chop at - line 6.
378########
379use warnings 'uninitialized';
380my ($m1);
381
382local $/ =\$m1;
383my $x = "abc";
384chomp $x; chop $x;
385my $y;
386chomp ($x, $y); chop ($x, $y);
387EXPECT
388Use of uninitialized value ${$/} in scalar chomp at - line 6.
389Use of uninitialized value ${$/} in chomp at - line 8.
390Use of uninitialized value $y in chomp at - line 8.
391Use of uninitialized value ${$/} in chomp at - line 8.
392Use of uninitialized value $y in chop at - line 8.
393########
394use warnings 'uninitialized';
395my ($m1, @ma, %mh);
396our ($g1);
397
398delete $ma[$m1];
399delete @ma[$m1, $g1];
400delete $mh{$m1};
401delete @mh{$m1, $g1};
402EXPECT
403Use of uninitialized value $m1 in delete at - line 5.
404Use of uninitialized value $m1 in delete at - line 6.
405Use of uninitialized value $g1 in delete at - line 6.
406Use of uninitialized value $m1 in delete at - line 7.
407Use of uninitialized value $m1 in delete at - line 8.
408Use of uninitialized value $g1 in delete at - line 8.
409########
410use warnings 'uninitialized';
411my ($m1, @ma, %mh);
412our ($g1);
413
414my @a = @ma[$m1, $g1];
415@a = (4,5)[$m1, $g1];
416@a = @mh{$m1, $g1};
417EXPECT
418Use of uninitialized value $m1 in array slice at - line 5.
419Use of uninitialized value $g1 in array slice at - line 5.
420Use of uninitialized value $m1 in list slice at - line 6.
421Use of uninitialized value $g1 in list slice at - line 6.
422Use of uninitialized value $m1 in hash slice at - line 7.
423Use of uninitialized value $g1 in hash slice at - line 7.
424########
425use warnings 'uninitialized';
426my ($m1, @ma, %mh, $v);
427our ($g1, @ga, %gh);
428
429$v = exists $ma[$m1];
430$v = exists $ga[$g1];
431$v = exists $mh{$m1};
432$v = exists $gh{$g1};
433EXPECT
434Use of uninitialized value $m1 in exists at - line 5.
435Use of uninitialized value $g1 in exists at - line 6.
436Use of uninitialized value $m1 in exists at - line 7.
437Use of uninitialized value $g1 in exists at - line 8.
438########
439use warnings 'uninitialized';
440my ($m1, $v);
441our ($g1);
442
443my ($x1,$x2);
444$v = $x1 << $m1;
445$v = $x2 << $g1;
446EXPECT
447Use of uninitialized value $m1 in left bitshift (<<) at - line 6.
448Use of uninitialized value $x1 in left bitshift (<<) at - line 6.
449Use of uninitialized value $g1 in left bitshift (<<) at - line 7.
450Use of uninitialized value $x2 in left bitshift (<<) at - line 7.
451########
452use warnings 'uninitialized';
453my ($m1, $m2, $v);
454our ($g1, $g2);
455
456use integer;
457$v = $m1 + $g1;
458$v = $m1 - $g1;
459$v = $m1 * $g1;
460eval {$v = $m1 / $g1};
461$v = $m2 / 2;
462eval {$v = $m1 % $g1};
463$v = $m2 % 2;
464$v = $m1 < $g1;
465$v = $m1 > $g1;
466$v = $m1 <= $g1;
467$v = $m1 >= $g1;
468$v = $m1 == $g1;
469$v = $m1 != $g1;
470$v = $m1 <=> $g1;
471$v = -$m1;
472EXPECT
473Use of uninitialized value $g1 in integer addition (+) at - line 6.
474Use of uninitialized value $m1 in integer addition (+) at - line 6.
475Use of uninitialized value $g1 in integer subtraction (-) at - line 7.
476Use of uninitialized value $m1 in integer subtraction (-) at - line 7.
477Use of uninitialized value $g1 in integer multiplication (*) at - line 8.
478Use of uninitialized value $m1 in integer multiplication (*) at - line 8.
479Use of uninitialized value $g1 in integer division (/) at - line 9.
480Use of uninitialized value $m2 in integer division (/) at - line 10.
481Use of uninitialized value $g1 in integer modulus (%) at - line 11.
482Use of uninitialized value $m1 in integer modulus (%) at - line 11.
483Use of uninitialized value $m2 in integer modulus (%) at - line 12.
484Use of uninitialized value $g1 in integer lt (<) at - line 13.
485Use of uninitialized value $m1 in integer lt (<) at - line 13.
486Use of uninitialized value $g1 in integer gt (>) at - line 14.
487Use of uninitialized value $m1 in integer gt (>) at - line 14.
488Use of uninitialized value $g1 in integer le (<=) at - line 15.
489Use of uninitialized value $m1 in integer le (<=) at - line 15.
490Use of uninitialized value $g1 in integer ge (>=) at - line 16.
491Use of uninitialized value $m1 in integer ge (>=) at - line 16.
492Use of uninitialized value $g1 in integer eq (==) at - line 17.
493Use of uninitialized value $m1 in integer eq (==) at - line 17.
494Use of uninitialized value $g1 in integer ne (!=) at - line 18.
495Use of uninitialized value $m1 in integer ne (!=) at - line 18.
496Use of uninitialized value $g1 in integer comparison (<=>) at - line 19.
497Use of uninitialized value $m1 in integer comparison (<=>) at - line 19.
498Use of uninitialized value $m1 in integer negation (-) at - line 20.
499########
500use warnings 'uninitialized';
501my ($m1, $m2, $v);
502our ($g1, $g2);
503
504$v = int($g1);
505$v = abs($g2);
506EXPECT
507Use of uninitialized value $g1 in int at - line 5.
508Use of uninitialized value $g1 in int at - line 5.
509Use of uninitialized value $g2 in abs at - line 6.
510Use of uninitialized value $g2 in abs at - line 6.
511########
512use warnings 'uninitialized';
513my ($m1, $m2, $v);
514our ($g1);
515
516$v = pack $m1;
517$v = pack "i*", $m2, $g1, $g2;
518my @unpack = unpack $m1, $m2;
519EXPECT
520Use of uninitialized value $m1 in pack at - line 5.
521Use of uninitialized value $m2 in pack at - line 6.
522Use of uninitialized value $g1 in pack at - line 6.
523Use of uninitialized value $g2 in pack at - line 6.
524Use of uninitialized value $m1 in unpack at - line 7.
525Use of uninitialized value $m2 in unpack at - line 7.
526########
527use warnings 'uninitialized';
528my ($m1);
529our ($g1);
530
531my @sort;
532@sort = sort $m1, $g1;
533@sort = sort {$a <=> $b} $m1, $g1;
534sub sortf {$a-1 <=> $b-1};
535@sort = sort &sortf, $m1, $g1;
536EXPECT
537Use of uninitialized value $m1 in sort at - line 6.
538Use of uninitialized value $g1 in sort at - line 6.
539Use of uninitialized value $m1 in sort at - line 6.
540Use of uninitialized value $g1 in sort at - line 6.
541Use of uninitialized value $m1 in sort at - line 7.
542Use of uninitialized value $g1 in sort at - line 7.
543Use of uninitialized value $m1 in sort at - line 7.
544Use of uninitialized value $g1 in sort at - line 7.
545Use of uninitialized value $a in subtraction (-) at - line 8.
546Use of uninitialized value $b in subtraction (-) at - line 8.
547Use of uninitialized value $m1 in sort at - line 9.
548Use of uninitialized value $g1 in sort at - line 9.
549Use of uninitialized value $m1 in sort at - line 9.
550Use of uninitialized value $m1 in sort at - line 9.
551Use of uninitialized value $g1 in sort at - line 9.
552Use of uninitialized value $g1 in sort at - line 9.
553########
554use warnings 'uninitialized';
555my ($m1, $m2, $v);
556our ($g1);
557
558eval { $v = $m1 / $g1 };
559$v = $m2 / 2;
560eval { $v = $m1 % $g1 };
561$v = $m2 % 2;
562$v = $m1 == $g1;
563$v = $m1 >= $g1;
564$v = $m1 > $g1;
565$v = $m1 <= $g1;
566$v = $m1 < $g1;
567$v = $m1 * $g1;
568$v = $m1 <=>$g1;
569$v = $m1 != $g1;
570$v = $m1 -$g1;
571$v = $m1 ** $g1;
572$v = $m1 + $g1;
573$v = $m1 - $g1;
574EXPECT
575Use of uninitialized value $g1 in division (/) at - line 5.
576Use of uninitialized value $m1 in division (/) at - line 5.
577Use of uninitialized value $m2 in division (/) at - line 6.
578Use of uninitialized value $g1 in modulus (%) at - line 7.
579Use of uninitialized value $m1 in modulus (%) at - line 7.
580Use of uninitialized value $m2 in modulus (%) at - line 8.
581Use of uninitialized value $g1 in numeric eq (==) at - line 9.
582Use of uninitialized value $m1 in numeric eq (==) at - line 9.
583Use of uninitialized value $g1 in numeric ge (>=) at - line 10.
584Use of uninitialized value $m1 in numeric ge (>=) at - line 10.
585Use of uninitialized value $g1 in numeric gt (>) at - line 11.
586Use of uninitialized value $m1 in numeric gt (>) at - line 11.
587Use of uninitialized value $g1 in numeric le (<=) at - line 12.
588Use of uninitialized value $m1 in numeric le (<=) at - line 12.
589Use of uninitialized value $g1 in numeric lt (<) at - line 13.
590Use of uninitialized value $m1 in numeric lt (<) at - line 13.
591Use of uninitialized value $g1 in multiplication (*) at - line 14.
592Use of uninitialized value $m1 in multiplication (*) at - line 14.
593Use of uninitialized value $g1 in numeric comparison (<=>) at - line 15.
594Use of uninitialized value $m1 in numeric comparison (<=>) at - line 15.
595Use of uninitialized value $g1 in numeric ne (!=) at - line 16.
596Use of uninitialized value $m1 in numeric ne (!=) at - line 16.
597Use of uninitialized value $g1 in subtraction (-) at - line 17.
598Use of uninitialized value $m1 in subtraction (-) at - line 17.
599Use of uninitialized value $g1 in exponentiation (**) at - line 18.
600Use of uninitialized value $m1 in exponentiation (**) at - line 18.
601Use of uninitialized value $g1 in addition (+) at - line 19.
602Use of uninitialized value $m1 in addition (+) at - line 19.
603Use of uninitialized value $g1 in subtraction (-) at - line 20.
604Use of uninitialized value $m1 in subtraction (-) at - line 20.
605########
606use warnings 'uninitialized';
607my ($m1, $v);
608our ($g1);
609
610$v = *global1{$m1};
611$v = prototype $g1;
612$v = bless [], $g1;
613$v = `$m1`;
614
615$v = $m1 . $g1;
616EXPECT
617Use of uninitialized value $m1 in glob elem at - line 5.
618Use of uninitialized value $g1 in subroutine prototype at - line 6.
619Use of uninitialized value $g1 in bless at - line 7.
620Use of uninitialized value $m1 in quoted execution (``, qx) at - line 8.
621Use of uninitialized value $g1 in concatenation (.) or string at - line 10.
622Use of uninitialized value $m1 in concatenation (.) or string at - line 10.
623########
624use warnings 'uninitialized';
625my ($m1);
626our ($g1, $g2);
627
628/y/;
629/$m1/;
630/$g1/;
631
632s/y/z/; undef $_;
633s/$m1/z/; undef $_;
634s//$g1/; undef $_;
635s/$m1/$g1/; undef $_;
636tr/x/y/; undef $_;
637
638my $_;
639/y/;
640/$m1/;
641/$g1/;
642s/y/z/; undef $_;
643s/$m1/z/; undef $_;
644s//$g1/; undef $_;
645s/$m1/$g1/; undef $_;
646tr/x/y/; undef $_;
647
648$g2 =~ /y/;
649$g2 =~ /$m1/;
650$g2 =~ /$g1/;
651$g2 =~ s/y/z/; undef $g2;
652$g2 =~ s/$m1/z/; undef $g2;
653$g2 =~ s//$g1/; undef $g2;
654$g2 =~ s/$m1/$g1/; undef $g2;
655$g2 =~ tr/x/y/; undef $g2; # XXX can't extract var name yet
656
657my $foo = "abc";
658$foo =~ /$m1/;
659$foo =~ /$g1/;
660$foo =~ s/y/z/;
661$foo =~ s/$m1/z/;
662$foo =~ s//$g1/;
663$foo =~ s/$m1/$g1/;
664$foo =~ s/./$m1/e;
665EXPECT
666Use of uninitialized value $_ in pattern match (m//) at - line 5.
667Use of uninitialized value $m1 in regexp compilation at - line 6.
668Use of uninitialized value $_ in pattern match (m//) at - line 6.
669Use of uninitialized value $g1 in regexp compilation at - line 7.
670Use of uninitialized value $_ in pattern match (m//) at - line 7.
671Use of uninitialized value $_ in substitution (s///) at - line 9.
672Use of uninitialized value $m1 in regexp compilation at - line 10.
673Use of uninitialized value $_ in substitution (s///) at - line 10.
674Use of uninitialized value $_ in substitution (s///) at - line 10.
675Use of uninitialized value $_ in substitution (s///) at - line 11.
676Use of uninitialized value $g1 in substitution (s///) at - line 11.
677Use of uninitialized value $_ in substitution (s///) at - line 11.
678Use of uninitialized value $g1 in substitution (s///) at - line 11.
679Use of uninitialized value $m1 in regexp compilation at - line 12.
680Use of uninitialized value $_ in substitution (s///) at - line 12.
681Use of uninitialized value $_ in substitution (s///) at - line 12.
682Use of uninitialized value $g1 in substitution iterator at - line 12.
683Use of uninitialized value $_ in transliteration (tr///) at - line 13.
684Use of uninitialized value $_ in pattern match (m//) at - line 16.
685Use of uninitialized value $m1 in regexp compilation at - line 17.
686Use of uninitialized value $_ in pattern match (m//) at - line 17.
687Use of uninitialized value $g1 in regexp compilation at - line 18.
688Use of uninitialized value $_ in pattern match (m//) at - line 18.
689Use of uninitialized value $_ in substitution (s///) at - line 19.
690Use of uninitialized value $m1 in regexp compilation at - line 20.
691Use of uninitialized value $_ in substitution (s///) at - line 20.
692Use of uninitialized value $_ in substitution (s///) at - line 20.
693Use of uninitialized value $_ in substitution (s///) at - line 21.
694Use of uninitialized value $g1 in substitution (s///) at - line 21.
695Use of uninitialized value $_ in substitution (s///) at - line 21.
696Use of uninitialized value $g1 in substitution (s///) at - line 21.
697Use of uninitialized value $m1 in regexp compilation at - line 22.
698Use of uninitialized value $_ in substitution (s///) at - line 22.
699Use of uninitialized value $_ in substitution (s///) at - line 22.
700Use of uninitialized value $g1 in substitution iterator at - line 22.
701Use of uninitialized value $_ in transliteration (tr///) at - line 23.
702Use of uninitialized value $g2 in pattern match (m//) at - line 25.
703Use of uninitialized value $m1 in regexp compilation at - line 26.
704Use of uninitialized value $g2 in pattern match (m//) at - line 26.
705Use of uninitialized value $g1 in regexp compilation at - line 27.
706Use of uninitialized value $g2 in pattern match (m//) at - line 27.
707Use of uninitialized value $g2 in substitution (s///) at - line 28.
708Use of uninitialized value $m1 in regexp compilation at - line 29.
709Use of uninitialized value $g2 in substitution (s///) at - line 29.
710Use of uninitialized value $g2 in substitution (s///) at - line 29.
711Use of uninitialized value $g2 in substitution (s///) at - line 30.
712Use of uninitialized value $g1 in substitution (s///) at - line 30.
713Use of uninitialized value $g2 in substitution (s///) at - line 30.
714Use of uninitialized value $g1 in substitution (s///) at - line 30.
715Use of uninitialized value $m1 in regexp compilation at - line 31.
716Use of uninitialized value $g2 in substitution (s///) at - line 31.
717Use of uninitialized value $g2 in substitution (s///) at - line 31.
718Use of uninitialized value $g1 in substitution iterator at - line 31.
719Use of uninitialized value in transliteration (tr///) at - line 32.
720Use of uninitialized value $m1 in regexp compilation at - line 35.
721Use of uninitialized value $g1 in regexp compilation at - line 36.
722Use of uninitialized value $m1 in regexp compilation at - line 38.
723Use of uninitialized value $g1 in substitution (s///) at - line 39.
724Use of uninitialized value $m1 in regexp compilation at - line 40.
725Use of uninitialized value $g1 in substitution iterator at - line 40.
726Use of uninitialized value $m1 in substitution iterator at - line 41.
727########
728use warnings 'uninitialized';
729my ($m1);
730
731{ my $foo = "abc"; (substr($foo,0,0)) = ($m1) }
732EXPECT
733Use of uninitialized value $m1 in list assignment at - line 4.
734########
735use warnings 'uninitialized';
736our ($g1);
737
738study;
739study $g1;
740EXPECT
741Use of uninitialized value $_ in study at - line 4.
742Use of uninitialized value $g1 in study at - line 5.
743########
744use warnings 'uninitialized';
745my ($m1);
746
747pos()=0;
748pos($m1)=0;
749EXPECT
750Use of uninitialized value $_ in scalar assignment at - line 4.
751Use of uninitialized value $m1 in scalar assignment at - line 5.
752########
753use warnings 'uninitialized';
754my ($m1);
755
756{ my $x = "a" x $m1 } # NB LHS of repeat does not warn
757{ my @x = ("a") x $m1 }
758EXPECT
759Use of uninitialized value $m1 in repeat (x) at - line 4.
760Use of uninitialized value $m1 in repeat (x) at - line 5.
761########
762use warnings 'uninitialized';
763my ($m1, $v);
764our ($g1);
765
766$v = "$m1";
767
768$v = $m1 lt $g1;
769$v = $m1 le $g1;
770$v = $m1 gt $g1;
771$v = $m1 ge $g1;
772$v = $m1 eq $g1;
773$v = $m1 ne $g1;
774$v = $m1 cmp $g1;
775EXPECT
776Use of uninitialized value $m1 in string at - line 5.
777Use of uninitialized value $m1 in string lt at - line 7.
778Use of uninitialized value $g1 in string lt at - line 7.
779Use of uninitialized value $m1 in string le at - line 8.
780Use of uninitialized value $g1 in string le at - line 8.
781Use of uninitialized value $m1 in string gt at - line 9.
782Use of uninitialized value $g1 in string gt at - line 9.
783Use of uninitialized value $m1 in string ge at - line 10.
784Use of uninitialized value $g1 in string ge at - line 10.
785Use of uninitialized value $m1 in string eq at - line 11.
786Use of uninitialized value $g1 in string eq at - line 11.
787Use of uninitialized value $m1 in string ne at - line 12.
788Use of uninitialized value $g1 in string ne at - line 12.
789Use of uninitialized value $m1 in string comparison (cmp) at - line 13.
790Use of uninitialized value $g1 in string comparison (cmp) at - line 13.
791########
792use warnings 'uninitialized';
793my ($m1, $v);
794our ($g1);
795
796$v = atan2($m1,$g1);
797$v = sin $m1;
798$v = cos $m1;
799$v = rand $m1;
800$v = srand $m1;
801$v = exp $m1;
802$v = eval {log $m1};
803$v = sqrt $m1;
804$v = hex $m1;
805$v = oct $m1;
806$v = length $m1;
807$v = length;
808EXPECT
809Use of uninitialized value $g1 in atan2 at - line 5.
810Use of uninitialized value $m1 in atan2 at - line 5.
811Use of uninitialized value $m1 in sin at - line 6.
812Use of uninitialized value $m1 in cos at - line 7.
813Use of uninitialized value $m1 in rand at - line 8.
814Use of uninitialized value $m1 in srand at - line 9.
815Use of uninitialized value $m1 in exp at - line 10.
816Use of uninitialized value $m1 in log at - line 11.
817Use of uninitialized value $m1 in sqrt at - line 12.
818Use of uninitialized value $m1 in hex at - line 13.
819Use of uninitialized value $m1 in oct at - line 14.
820Use of uninitialized value $m1 in length at - line 15.
821Use of uninitialized value $_ in length at - line 16.
822########
823use warnings 'uninitialized';
824my ($m1, $v);
825our ($g1);
826
827$v = substr $m1, $g1;
828$v = substr $m1, $g1, $m2;
829$v = substr $m1, $g1, $m2, $g2; undef $m1;
830substr($m1, $g1) = $g2; undef $m1; # NB global2
831substr($m1, $g1, $m2) = $g2; undef $m1; # isn't identified
832
833$v = eval {vec ($m1, $g1, $m2)};
834eval {vec ($m1, $g1, $m2) = $g2}; undef $m1; # ditto
835
836$v = index $m1, $m2;
837$v = index $m1, $m2, $g1;
838$v = rindex $m1, $m2;
839$v = rindex $m1, $m2, $g1;
840EXPECT
841Use of uninitialized value $g1 in substr at - line 5.
842Use of uninitialized value $m1 in substr at - line 5.
843Use of uninitialized value $m2 in substr at - line 6.
844Use of uninitialized value $g1 in substr at - line 6.
845Use of uninitialized value $m1 in substr at - line 6.
846Use of uninitialized value $g2 in substr at - line 7.
847Use of uninitialized value $m2 in substr at - line 7.
848Use of uninitialized value $g1 in substr at - line 7.
849Use of uninitialized value $m1 in substr at - line 7.
850Use of uninitialized value $m1 in substr at - line 7.
851Use of uninitialized value $g1 in substr at - line 8.
852Use of uninitialized value $m1 in substr at - line 8.
853Use of uninitialized value in scalar assignment at - line 8.
854Use of uninitialized value $m2 in substr at - line 9.
855Use of uninitialized value $g1 in substr at - line 9.
856Use of uninitialized value $m1 in substr at - line 9.
857Use of uninitialized value in scalar assignment at - line 9.
858Use of uninitialized value $m2 in vec at - line 11.
859Use of uninitialized value $g1 in vec at - line 11.
860Use of uninitialized value $m1 in vec at - line 11.
861Use of uninitialized value $m2 in vec at - line 12.
862Use of uninitialized value $g1 in vec at - line 12.
863Use of uninitialized value $m1 in vec at - line 12.
864Use of uninitialized value $m1 in index at - line 14.
865Use of uninitialized value $m2 in index at - line 14.
866Use of uninitialized value $g1 in index at - line 15.
867Use of uninitialized value $m1 in index at - line 15.
868Use of uninitialized value $m2 in index at - line 15.
869Use of uninitialized value $m2 in rindex at - line 16.
870Use of uninitialized value $m1 in rindex at - line 16.
871Use of uninitialized value $g1 in rindex at - line 17.
872Use of uninitialized value $m2 in rindex at - line 17.
873Use of uninitialized value $m1 in rindex at - line 17.
874########
875use warnings 'uninitialized';
876my ($m1, $v);
877our ($g1);
878
879$v = sprintf $m1;
880$v = sprintf '%d%d%d%d', $m1, $m2, $g1, $g2;
881eval {formline $m1 }; undef $m1;
882formline '@<<@<<@<<@<<', $m1, $m2, $g1, $g2;
883EXPECT
884Use of uninitialized value $m1 in sprintf at - line 5.
885Use of uninitialized value $m1 in sprintf at - line 6.
886Use of uninitialized value $m2 in sprintf at - line 6.
887Use of uninitialized value $g1 in sprintf at - line 6.
888Use of uninitialized value $g2 in sprintf at - line 6.
889Use of uninitialized value $m1 in formline at - line 7.
890Use of uninitialized value $m1 in formline at - line 8.
891Use of uninitialized value $m2 in formline at - line 8.
892Use of uninitialized value $g1 in formline at - line 8.
893Use of uninitialized value $g2 in formline at - line 8.
894########
895use warnings 'uninitialized';
896my ($m1, $v);
897our ($g1);
898
899$v = crypt $m1, $g1;
900
901$v = ord;
902$v = ord $m1;
903$v = chr;
904$v = chr $m1;
905
906# XXX these functions don't warn!
907$v = ucfirst;
908$v = ucfirst $m1;
909$v = lcfirst;
910$v = lcfirst $m1;
911$v = uc;
912$v = uc $m1;
913$v = lc;
914$v = lc $m1;
915
916$v = quotemeta;
917$v = quotemeta $m1;
918EXPECT
919Use of uninitialized value $m1 in crypt at - line 5.
920Use of uninitialized value $g1 in crypt at - line 5.
921Use of uninitialized value $_ in ord at - line 7.
922Use of uninitialized value $m1 in ord at - line 8.
923Use of uninitialized value $_ in chr at - line 9.
924Use of uninitialized value $m1 in chr at - line 10.
925Use of uninitialized value $_ in quotemeta at - line 22.
926Use of uninitialized value $m1 in quotemeta at - line 23.
927########
928use warnings 'uninitialized';
929my ($m1, $v1, $v2, $v3, $v4);
930our ($g1);
931
932($v1,$v2,$v3,$v4) = split;
933($v1,$v2,$v3,$v4) = split $m1;
934($v1,$v2,$v3,$v4) = split $m1, $m2;
935($v1,$v2,$v3,$v4) = split $m1, $m2, $g1;
936
937$v1 = join $m1;
938$v2 = join $m1, $m2;
939$v3 = join $m1, $m2, $m3;
940EXPECT
941Use of uninitialized value $_ in split at - line 5.
942Use of uninitialized value $m1 in regexp compilation at - line 6.
943Use of uninitialized value $_ in split at - line 6.
944Use of uninitialized value $m1 in regexp compilation at - line 7.
945Use of uninitialized value $m2 in split at - line 7.
946Use of uninitialized value $m1 in regexp compilation at - line 8.
947Use of uninitialized value $g1 in split at - line 8.
948Use of uninitialized value $m2 in split at - line 8.
949Use of uninitialized value $m1 in join or string at - line 10.
950Use of uninitialized value $m1 in join or string at - line 11.
951Use of uninitialized value $m2 in join or string at - line 11.
952Use of uninitialized value $m1 in join or string at - line 12.
953Use of uninitialized value $m2 in join or string at - line 12.
954Use of uninitialized value $m3 in join or string at - line 12.
955########
956use warnings 'uninitialized';
957my ($m1, $m2, @ma, $v);
958
959our @foo1=(1,undef); chomp @foo1;
960my @foo2=(1,undef); chomp @foo2;
961our @foo3=(1,undef); chop @foo3;
962my @foo4=(1,undef); chop @foo4;
963our @foo5=(1,undef); $v = sprintf "%s%s",@foo5;
964my @foo6=(1,undef); $v = sprintf "%s%s",@foo6;
965our %foo7=('foo'=>'bar','baz'=>undef); $v = sprintf "%s%s",%foo7;
966my %foo8=('foo'=>'bar','baz'=>undef); $v = sprintf "%s%s",%foo8;
967our @foo9 =(1,undef); $v = sprintf "%s%s%s%s",$m1,@foo9, $ma[2];
968my @foo10=(1,undef); $v = sprintf "%s%s%s%s",$m2,@foo10,$ma[2];
969our %foo11=('foo'=>'bar','baz'=>undef); $v = join '', %foo11;
970my %foo12=('foo'=>'bar','baz'=>undef); $v = join '', %foo12;
971our %foo13=(1..2000,'foo'=>'bar','baz'=>undef); $v = join '', %foo13;
972my %foo14=(1..2000,'foo'=>'bar','baz'=>undef); $v = join '', %foo14;
973EXPECT
974Use of uninitialized value $foo1[1] in chomp at - line 4.
975Use of uninitialized value $foo2[1] in chomp at - line 5.
976Use of uninitialized value $foo3[1] in chop at - line 6.
977Use of uninitialized value $foo4[1] in chop at - line 7.
978Use of uninitialized value $foo5[1] in sprintf at - line 8.
979Use of uninitialized value $foo6[1] in sprintf at - line 9.
980Use of uninitialized value $foo7{"baz"} in sprintf at - line 10.
981Use of uninitialized value $foo8{"baz"} in sprintf at - line 11.
982Use of uninitialized value $m1 in sprintf at - line 12.
983Use of uninitialized value $foo9[1] in sprintf at - line 12.
984Use of uninitialized value in sprintf at - line 12.
985Use of uninitialized value $m2 in sprintf at - line 13.
986Use of uninitialized value $foo10[1] in sprintf at - line 13.
987Use of uninitialized value in sprintf at - line 13.
988Use of uninitialized value $foo11{"baz"} in join or string at - line 14.
989Use of uninitialized value $foo12{"baz"} in join or string at - line 15.
990Use of uninitialized value within %foo13 in join or string at - line 16.
991Use of uninitialized value within %foo14 in join or string at - line 17.
992########
993use warnings 'uninitialized';
994my ($v);
995
996undef $^A; $v = $^A + ${^FOO}; # should output '^A' not chr(1)
997*GLOB1 = *GLOB2;
998$v = $GLOB1 + 1;
999$v = $GLOB2 + 1;
1000EXPECT
1001Use of uninitialized value $^FOO in addition (+) at - line 4.
1002Use of uninitialized value $^A in addition (+) at - line 4.
1003Use of uninitialized value $GLOB1 in addition (+) at - line 6.
1004Use of uninitialized value $GLOB2 in addition (+) at - line 7.
1005########
1006use warnings 'uninitialized';
1007my ($v);
1008
1009# check hash key is sanitised
1010my %h = ("\0011\002\r\n\t\f\"\\abcdefghijklmnopqrstuvwxyz", undef);
1011$v = join '', %h;
1012EXPECT
1013Use of uninitialized value $h{"\0011\2\r\n\t\f\"\\abcdefghijkl"...} in join or string at - line 6.
1014########
1015use warnings 'uninitialized';
1016my ($m1, $v);
1017our ($g1);
1018
1019$v = eval { \&$m1 };
1020$v = eval { \&$g1 };
1021
1022my @a;
1023@a = splice @a, $m1, $g1;
1024$v = 1 + splice @a, $m1, $g1;
1025
1026my $x = bless [], 'Z';
1027eval { $x->$m1() };
1028
1029eval { &$m1() };
1030eval { &$g1() };
1031
1032warn $m1,$g1,"foo";
1033
1034eval { die $m1, $g1 };
1035
1036reset $m1;
1037reset $g1;
1038EXPECT
1039Use of uninitialized value $m1 in subroutine dereference at - line 5.
1040Use of uninitialized value $m1 in subroutine dereference at - line 5.
1041Use of uninitialized value $g1 in subroutine dereference at - line 6.
1042Use of uninitialized value $g1 in subroutine dereference at - line 6.
1043Use of uninitialized value $m1 in splice at - line 9.
1044Use of uninitialized value $g1 in splice at - line 9.
1045Use of uninitialized value $m1 in splice at - line 10.
1046Use of uninitialized value $g1 in splice at - line 10.
1047Use of uninitialized value in addition (+) at - line 10.
1048Use of uninitialized value $m1 in method lookup at - line 13.
1049Use of uninitialized value $m1 in subroutine entry at - line 15.
1050Use of uninitialized value $g1 in subroutine entry at - line 16.
1051Use of uninitialized value $m1 in warn at - line 18.
1052Use of uninitialized value $g1 in warn at - line 18.
1053foo at - line 18.
1054Use of uninitialized value $m1 in die at - line 20.
1055Use of uninitialized value $g1 in die at - line 20.
1056Use of uninitialized value $m1 in symbol reset at - line 22.
1057Use of uninitialized value $g1 in symbol reset at - line 23.
1058########
1059use warnings 'uninitialized';
1060my ($m1);
1061our ($g1);
1062
1063open FOO; # accesses $FOO
1064my $foo = 'FO';
1065open($foo."O"); # accesses $FOO
1066open my $x; # accesses ${*$x}
1067open $foobar; # accesses ${*$foobar}
1068my $y;
1069open $y, $m1;
1070eval { open $y, $m1, $g1 };
1071open $y, '<', $g1;
1072
1073sysopen $y, $m1, $m2;
1074sysopen $y, $m1, $g1, $m2;
1075
1076my $old = umask;
1077umask $m1;
1078umask $g1;
1079umask $old;
1080
1081binmode STDIN, $m1;
1082EXPECT
1083Use of uninitialized value $FOO in open at - line 5.
1084Use of uninitialized value in open at - line 7.
1085Use of uninitialized value in open at - line 8.
1086Use of uninitialized value in open at - line 9.
1087Use of uninitialized value $m1 in open at - line 11.
1088Use of uninitialized value $m1 in open at - line 12.
1089Use of uninitialized value $g1 in open at - line 13.
1090Use of uninitialized value $m2 in sysopen at - line 15.
1091Use of uninitialized value $m1 in sysopen at - line 15.
1092Use of uninitialized value $m2 in sysopen at - line 16.
1093Use of uninitialized value $g1 in sysopen at - line 16.
1094Use of uninitialized value $m1 in sysopen at - line 16.
1095Use of uninitialized value $m1 in umask at - line 19.
1096Use of uninitialized value $g1 in umask at - line 20.
1097Use of uninitialized value $m1 in binmode at - line 23.
1098Use of uninitialized value $m1 in binmode at - line 23.
1099########
1100use warnings 'uninitialized';
1101my ($m1);
1102our ($g1);
1103
1104eval { my $x; tie $x, $m1 };
1105
1106eval { my $x; read $m1, $x, $g1 };
1107eval { my $x; read $m1, $x, $g1, $g2 };
1108eval { my $x; sysread $m1, $x, $g1 };
1109eval { my $x; sysread $m1, $x, $g1, $g2 };
1110EXPECT
1111Use of uninitialized value $m1 in tie at - line 5.
1112Use of uninitialized value $m1 in tie at - line 5.
1113Use of uninitialized value $m1 in ref-to-glob cast at - line 7.
1114Use of uninitialized value $g1 in read at - line 7.
1115Use of uninitialized value $m1 in ref-to-glob cast at - line 8.
1116Use of uninitialized value $g1 in read at - line 8.
1117Use of uninitialized value $g2 in read at - line 8.
1118Use of uninitialized value $m1 in ref-to-glob cast at - line 9.
1119Use of uninitialized value $g1 in sysread at - line 9.
1120Use of uninitialized value $m1 in ref-to-glob cast at - line 10.
1121Use of uninitialized value $g1 in sysread at - line 10.
1122Use of uninitialized value $g2 in sysread at - line 10.
1123########
1124use warnings 'uninitialized';
1125my ($m1);
1126our ($g1, @ga);
1127
1128printf $m1;
1129printf STDERR "%d%d%d%d\n", $m1, $m2, $g1, $g2;
1130printf $ga[1000];
1131printf STDERR "FOO1:%s\n", $ga[1000];
1132printf STDERR "FOO2:%s%s%s%s\n", $m1, $g1, $ga[1],$m2;
1133printf STDERR "FOO3:%s%s%s\n", "X", $ga[1],"Y";
1134EXPECT
1135Use of uninitialized value $m1 in printf at - line 5.
1136Use of uninitialized value $m1 in printf at - line 6.
1137Use of uninitialized value $m2 in printf at - line 6.
1138Use of uninitialized value $g1 in printf at - line 6.
1139Use of uninitialized value $g2 in printf at - line 6.
11400000
1141Use of uninitialized value $ga[1000] in printf at - line 7.
1142Use of uninitialized value $ga[1000] in printf at - line 8.
1143FOO1:
1144Use of uninitialized value $m1 in printf at - line 9.
1145Use of uninitialized value $g1 in printf at - line 9.
1146Use of uninitialized value in printf at - line 9.
1147Use of uninitialized value $m2 in printf at - line 9.
1148FOO2:
1149Use of uninitialized value $ga[1] in printf at - line 10.
1150FOO3:XY
1151########
1152use warnings 'uninitialized';
1153my ($m1);
1154our ($g1);
1155
1156eval { my $x; seek $x,$m1, $g1 };
1157eval { my $x; sysseek $x,$m1, $g1 };
1158eval { syswrite $m1, $g1 };
1159eval { syswrite STDERR, $m1 };
1160eval { syswrite STDERR, $m1, $g1 };
1161eval { syswrite STDERR, $m1, $g1, $m2 };
1162eval { my $x; flock $x, $g1 };
1163eval { my $x; socket $x, $m1, $g1, $m2 };
1164eval { my ($x,$y); socketpair $x, $y, $m1, $g1, $m2 };
1165EXPECT
1166Use of uninitialized value $x in ref-to-glob cast at - line 5.
1167Use of uninitialized value $g1 in seek at - line 5.
1168Use of uninitialized value $m1 in seek at - line 5.
1169Use of uninitialized value $x in ref-to-glob cast at - line 6.
1170Use of uninitialized value $g1 in sysseek at - line 6.
1171Use of uninitialized value $m1 in sysseek at - line 6.
1172Use of uninitialized value $m1 in ref-to-glob cast at - line 7.
1173Use of uninitialized value $g1 in syswrite at - line 7.
1174Use of uninitialized value $m1 in syswrite at - line 8.
1175Use of uninitialized value $m1 in syswrite at - line 8.
1176Use of uninitialized value $g1 in syswrite at - line 9.
1177Use of uninitialized value $m1 in syswrite at - line 9.
1178Use of uninitialized value $g1 in syswrite at - line 10.
1179Use of uninitialized value $m1 in syswrite at - line 10.
1180Use of uninitialized value $m2 in syswrite at - line 10.
1181Use of uninitialized value $x in ref-to-glob cast at - line 11.
1182Use of uninitialized value $g1 in flock at - line 11.
1183Use of uninitialized value $m2 in socket at - line 12.
1184Use of uninitialized value $g1 in socket at - line 12.
1185Use of uninitialized value $m1 in socket at - line 12.
1186Use of uninitialized value $m2 in socketpair at - line 13.
1187Use of uninitialized value $g1 in socketpair at - line 13.
1188Use of uninitialized value $m1 in socketpair at - line 13.
1189########
1190use warnings 'uninitialized';
1191my ($m1, $v);
1192our ($g1);
1193
1194stat;
1195lstat;
1196stat $m1;
1197lstat $g1;
1198
1199$v = -R $m1;
1200$v = -W $m1;
1201$v = -X $m1;
1202$v = -r $m1;
1203$v = -w $m1;
1204$v = -x $m1;
1205$v = -e $m1;
1206$v = -O $m1;
1207$v = -o $m1;
1208$v = -z $m1;
1209$v = -s $m1;
1210$v = -M $m1;
1211$v = -A $m1;
1212$v = -C $m1;
1213$v = -S $m1;
1214$v = -c $m1;
1215$v = -b $m1;
1216$v = -f $m1;
1217$v = -d $m1;
1218$v = -p $m1;
1219$v = -l $m1;
1220$v = -u $m1;
1221$v = -g $m1;
1222$v = -k $m1;
1223$v = -t $m1;
1224$v = -T $m1;
1225$v = -B $m1;
1226EXPECT
1227Use of uninitialized value $_ in stat at - line 5.
1228Use of uninitialized value $_ in lstat at - line 6.
1229Use of uninitialized value $m1 in stat at - line 7.
1230Use of uninitialized value $g1 in lstat at - line 8.
1231Use of uninitialized value $m1 in -R at - line 10.
1232Use of uninitialized value $m1 in -W at - line 11.
1233Use of uninitialized value $m1 in -X at - line 12.
1234Use of uninitialized value $m1 in -r at - line 13.
1235Use of uninitialized value $m1 in -w at - line 14.
1236Use of uninitialized value $m1 in -x at - line 15.
1237Use of uninitialized value $m1 in -e at - line 16.
1238Use of uninitialized value $m1 in -o at - line 17.
1239Use of uninitialized value $m1 in -O at - line 18.
1240Use of uninitialized value $m1 in -z at - line 19.
1241Use of uninitialized value $m1 in -s at - line 20.
1242Use of uninitialized value $m1 in -M at - line 21.
1243Use of uninitialized value $m1 in -A at - line 22.
1244Use of uninitialized value $m1 in -C at - line 23.
1245Use of uninitialized value $m1 in -S at - line 24.
1246Use of uninitialized value $m1 in -c at - line 25.
1247Use of uninitialized value $m1 in -b at - line 26.
1248Use of uninitialized value $m1 in -f at - line 27.
1249Use of uninitialized value $m1 in -d at - line 28.
1250Use of uninitialized value $m1 in -p at - line 29.
1251Use of uninitialized value $m1 in -l at - line 30.
1252Use of uninitialized value $m1 in -l at - line 30.
1253Use of uninitialized value $m1 in -u at - line 31.
1254Use of uninitialized value $m1 in -g at - line 32.
1255Use of uninitialized value $m1 in -k at - line 33.
1256Use of uninitialized value $m1 in -t at - line 34.
1257Use of uninitialized value $m1 in -T at - line 35.
1258Use of uninitialized value $m1 in -B at - line 36.
1259########
1260use warnings 'uninitialized';
1261my ($m1, $v);
1262our ($g1);
1263
1264$v = localtime $m1;
1265$v = gmtime $g1;
1266EXPECT
1267Use of uninitialized value $m1 in localtime at - line 5.
1268Use of uninitialized value $g1 in gmtime at - line 6.
1269########
1270use warnings 'uninitialized';
1271my ($m1, $v);
1272
1273$v = eval;
1274$v = eval $m1;
1275EXPECT
1276Use of uninitialized value $_ in eval "string" at - line 4.
1277Use of uninitialized value $_ in eval "string" at - line 4.
1278Use of uninitialized value $_ in eval "string" at - line 4.
1279Use of uninitialized value $m1 in eval "string" at - line 5.
1280Use of uninitialized value $m1 in eval "string" at - line 5.
1281Use of uninitialized value $m1 in eval "string" at - line 5.
1282########
1283use warnings 'uninitialized';
1284my ($m1);
1285
1286exit $m1;
1287EXPECT
1288Use of uninitialized value $m1 in exit at - line 4.