This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Assimilate Test-Simple 0.50
[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;
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.
628Use of uninitialized value $g1 in concatenation (.) or string at - line 10.
629Use of uninitialized value $m1 in concatenation (.) or string at - line 10.
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;
672EXPECT
673Use of uninitialized value $_ in pattern match (m//) at - line 5.
674Use of uninitialized value $m1 in regexp compilation at - line 6.
675Use of uninitialized value $_ in pattern match (m//) at - line 6.
676Use of uninitialized value $g1 in regexp compilation at - line 7.
677Use of uninitialized value $_ in pattern match (m//) at - line 7.
678Use of uninitialized value $_ in substitution (s///) at - line 9.
679Use of uninitialized value $m1 in regexp compilation at - line 10.
680Use of uninitialized value $_ in substitution (s///) at - line 10.
681Use of uninitialized value $_ in substitution (s///) at - line 10.
682Use of uninitialized value $_ in substitution (s///) at - line 11.
683Use of uninitialized value $g1 in substitution (s///) at - line 11.
684Use of uninitialized value $_ in substitution (s///) at - line 11.
685Use of uninitialized value $g1 in substitution (s///) at - line 11.
686Use of uninitialized value $m1 in regexp compilation at - line 12.
687Use of uninitialized value $_ in substitution (s///) at - line 12.
688Use of uninitialized value $_ in substitution (s///) at - line 12.
689Use of uninitialized value $g1 in substitution iterator at - line 12.
690Use of uninitialized value $_ in transliteration (tr///) at - line 13.
691Use of uninitialized value $_ in pattern match (m//) at - line 16.
692Use of uninitialized value $m1 in regexp compilation at - line 17.
693Use of uninitialized value $_ in pattern match (m//) at - line 17.
694Use of uninitialized value $g1 in regexp compilation at - line 18.
695Use of uninitialized value $_ in pattern match (m//) at - line 18.
696Use of uninitialized value $_ in substitution (s///) at - line 19.
697Use of uninitialized value $m1 in regexp compilation at - line 20.
698Use of uninitialized value $_ in substitution (s///) at - line 20.
699Use of uninitialized value $_ in substitution (s///) at - line 20.
700Use of uninitialized value $_ in substitution (s///) at - line 21.
701Use of uninitialized value $g1 in substitution (s///) at - line 21.
702Use of uninitialized value $_ in substitution (s///) at - line 21.
703Use of uninitialized value $g1 in substitution (s///) at - line 21.
704Use of uninitialized value $m1 in regexp compilation at - line 22.
705Use of uninitialized value $_ in substitution (s///) at - line 22.
706Use of uninitialized value $_ in substitution (s///) at - line 22.
707Use of uninitialized value $g1 in substitution iterator at - line 22.
708Use of uninitialized value $_ in transliteration (tr///) at - line 23.
709Use of uninitialized value $g2 in pattern match (m//) at - line 25.
710Use of uninitialized value $m1 in regexp compilation at - line 26.
711Use of uninitialized value $g2 in pattern match (m//) at - line 26.
712Use of uninitialized value $g1 in regexp compilation at - line 27.
713Use of uninitialized value $g2 in pattern match (m//) at - line 27.
714Use of uninitialized value $g2 in substitution (s///) at - line 28.
715Use of uninitialized value $m1 in regexp compilation at - line 29.
716Use of uninitialized value $g2 in substitution (s///) at - line 29.
717Use of uninitialized value $g2 in substitution (s///) at - line 29.
718Use of uninitialized value $g2 in substitution (s///) at - line 30.
719Use of uninitialized value $g1 in substitution (s///) at - line 30.
720Use of uninitialized value $g2 in substitution (s///) at - line 30.
721Use of uninitialized value $g1 in substitution (s///) at - line 30.
722Use of uninitialized value $m1 in regexp compilation at - line 31.
723Use of uninitialized value $g2 in substitution (s///) at - line 31.
724Use of uninitialized value $g2 in substitution (s///) at - line 31.
725Use of uninitialized value $g1 in substitution iterator at - line 31.
726Use of uninitialized value in transliteration (tr///) at - line 32.
727Use of uninitialized value $m1 in regexp compilation at - line 35.
728Use of uninitialized value $g1 in regexp compilation at - line 36.
729Use of uninitialized value $m1 in regexp compilation at - line 38.
730Use of uninitialized value $g1 in substitution (s///) at - line 39.
731Use of uninitialized value $m1 in regexp compilation at - line 40.
732Use of uninitialized value $g1 in substitution iterator at - line 40.
733Use of uninitialized value $m1 in substitution iterator at - line 41.
734########
735use warnings 'uninitialized';
736my ($m1);
737
738{ my $foo = "abc"; (substr($foo,0,0)) = ($m1) }
739EXPECT
740Use of uninitialized value $m1 in list assignment at - line 4.
741########
742use warnings 'uninitialized';
743our ($g1);
744
745study;
746study $g1;
747EXPECT
748Use of uninitialized value $_ in study at - line 4.
749Use of uninitialized value $g1 in study at - line 5.
750########
751use warnings 'uninitialized';
752my ($m1);
753
754pos()=0;
755pos($m1)=0;
756EXPECT
757Use of uninitialized value $_ in scalar assignment at - line 4.
758Use of uninitialized value $m1 in scalar assignment at - line 5.
759########
760use warnings 'uninitialized';
761my ($m1);
762
763{ my $x = "a" x $m1 } # NB LHS of repeat does not warn
764{ my @x = ("a") x $m1 }
765EXPECT
766Use of uninitialized value $m1 in repeat (x) at - line 4.
767Use of uninitialized value $m1 in repeat (x) at - line 5.
768########
769use warnings 'uninitialized';
770my ($m1, $v);
771our ($g1);
772
773$v = "$m1";
774
775$v = $m1 lt $g1;
776$v = $m1 le $g1;
777$v = $m1 gt $g1;
778$v = $m1 ge $g1;
779$v = $m1 eq $g1;
780$v = $m1 ne $g1;
781$v = $m1 cmp $g1;
782EXPECT
783Use of uninitialized value $m1 in string at - line 5.
784Use of uninitialized value $m1 in string lt at - line 7.
785Use of uninitialized value $g1 in string lt at - line 7.
786Use of uninitialized value $m1 in string le at - line 8.
787Use of uninitialized value $g1 in string le at - line 8.
788Use of uninitialized value $m1 in string gt at - line 9.
789Use of uninitialized value $g1 in string gt at - line 9.
790Use of uninitialized value $m1 in string ge at - line 10.
791Use of uninitialized value $g1 in string ge at - line 10.
792Use of uninitialized value $m1 in string eq at - line 11.
793Use of uninitialized value $g1 in string eq at - line 11.
794Use of uninitialized value $m1 in string ne at - line 12.
795Use of uninitialized value $g1 in string ne at - line 12.
796Use of uninitialized value $m1 in string comparison (cmp) at - line 13.
797Use of uninitialized value $g1 in string comparison (cmp) at - line 13.
798########
799use warnings 'uninitialized';
800my ($m1, $v);
801our ($g1);
802
803$v = atan2($m1,$g1);
804$v = sin $m1;
805$v = cos $m1;
806$v = rand $m1;
807$v = srand $m1;
808$v = exp $m1;
809$v = eval {log $m1};
810$v = sqrt $m1;
811$v = hex $m1;
812$v = oct $m1;
813$v = length $m1;
814$v = length;
815EXPECT
816Use of uninitialized value $g1 in atan2 at - line 5.
817Use of uninitialized value $m1 in atan2 at - line 5.
818Use of uninitialized value $m1 in sin at - line 6.
819Use of uninitialized value $m1 in cos at - line 7.
820Use of uninitialized value $m1 in rand at - line 8.
821Use of uninitialized value $m1 in srand at - line 9.
822Use of uninitialized value $m1 in exp at - line 10.
823Use of uninitialized value $m1 in log at - line 11.
824Use of uninitialized value $m1 in sqrt at - line 12.
825Use of uninitialized value $m1 in hex at - line 13.
826Use of uninitialized value $m1 in oct at - line 14.
827Use of uninitialized value $m1 in length at - line 15.
828Use of uninitialized value $_ in length at - line 16.
829########
830use warnings 'uninitialized';
831my ($m1, $v);
832our ($g1);
833
834$v = substr $m1, $g1;
835$v = substr $m1, $g1, $m2;
836$v = substr $m1, $g1, $m2, $g2; undef $m1;
837substr($m1, $g1) = $g2; undef $m1; # NB global2
838substr($m1, $g1, $m2) = $g2; undef $m1; # isn't identified
839
840$v = eval {vec ($m1, $g1, $m2)};
841eval {vec ($m1, $g1, $m2) = $g2}; undef $m1; # ditto
842
843$v = index $m1, $m2;
844$v = index $m1, $m2, $g1;
845$v = rindex $m1, $m2;
846$v = rindex $m1, $m2, $g1;
847EXPECT
848Use of uninitialized value $g1 in substr at - line 5.
849Use of uninitialized value $m1 in substr at - line 5.
850Use of uninitialized value $m2 in substr at - line 6.
851Use of uninitialized value $g1 in substr at - line 6.
852Use of uninitialized value $m1 in substr at - line 6.
853Use of uninitialized value $g2 in substr at - line 7.
854Use of uninitialized value $m2 in substr at - line 7.
855Use of uninitialized value $g1 in substr at - line 7.
856Use of uninitialized value $m1 in substr at - line 7.
857Use of uninitialized value $m1 in substr at - line 7.
858Use of uninitialized value $g1 in substr at - line 8.
859Use of uninitialized value $m1 in substr at - line 8.
860Use of uninitialized value in scalar assignment at - line 8.
861Use of uninitialized value $m2 in substr at - line 9.
862Use of uninitialized value $g1 in substr at - line 9.
863Use of uninitialized value $m1 in substr at - line 9.
864Use of uninitialized value in scalar assignment at - line 9.
865Use of uninitialized value $m2 in vec at - line 11.
866Use of uninitialized value $g1 in vec at - line 11.
867Use of uninitialized value $m1 in vec at - line 11.
868Use of uninitialized value $m2 in vec at - line 12.
869Use of uninitialized value $g1 in vec at - line 12.
870Use of uninitialized value $m1 in vec at - line 12.
871Use of uninitialized value $m1 in index at - line 14.
872Use of uninitialized value $m2 in index at - line 14.
873Use of uninitialized value $g1 in index at - line 15.
874Use of uninitialized value $m1 in index at - line 15.
875Use of uninitialized value $m2 in index at - line 15.
876Use of uninitialized value $m2 in rindex at - line 16.
877Use of uninitialized value $m1 in rindex at - line 16.
878Use of uninitialized value $g1 in rindex at - line 17.
879Use of uninitialized value $m2 in rindex at - line 17.
880Use of uninitialized value $m1 in rindex at - line 17.
881########
882use warnings 'uninitialized';
883my ($m1, $v);
884our ($g1);
885
886$v = sprintf $m1;
887$v = sprintf '%d%d%d%d', $m1, $m2, $g1, $g2;
094236a2 888my $m3; eval {formline $m3 };
29489e7c
DM
889formline '@<<@<<@<<@<<', $m1, $m2, $g1, $g2;
890EXPECT
891Use of uninitialized value $m1 in sprintf at - line 5.
892Use of uninitialized value $m1 in sprintf at - line 6.
893Use of uninitialized value $m2 in sprintf at - line 6.
894Use of uninitialized value $g1 in sprintf at - line 6.
895Use of uninitialized value $g2 in sprintf at - line 6.
094236a2 896Use of uninitialized value $m3 in formline at - line 7.
29489e7c
DM
897Use of uninitialized value $m1 in formline at - line 8.
898Use of uninitialized value $m2 in formline at - line 8.
899Use of uninitialized value $g1 in formline at - line 8.
900Use of uninitialized value $g2 in formline at - line 8.
901########
902use warnings 'uninitialized';
903my ($m1, $v);
904our ($g1);
905
906$v = crypt $m1, $g1;
907
908$v = ord;
909$v = ord $m1;
910$v = chr;
911$v = chr $m1;
912
913# XXX these functions don't warn!
914$v = ucfirst;
915$v = ucfirst $m1;
916$v = lcfirst;
917$v = lcfirst $m1;
918$v = uc;
919$v = uc $m1;
920$v = lc;
921$v = lc $m1;
922
923$v = quotemeta;
924$v = quotemeta $m1;
925EXPECT
926Use of uninitialized value $m1 in crypt at - line 5.
927Use of uninitialized value $g1 in crypt at - line 5.
928Use of uninitialized value $_ in ord at - line 7.
929Use of uninitialized value $m1 in ord at - line 8.
930Use of uninitialized value $_ in chr at - line 9.
931Use of uninitialized value $m1 in chr at - line 10.
932Use of uninitialized value $_ in quotemeta at - line 22.
933Use of uninitialized value $m1 in quotemeta at - line 23.
934########
935use warnings 'uninitialized';
936my ($m1, $v1, $v2, $v3, $v4);
937our ($g1);
938
939($v1,$v2,$v3,$v4) = split;
940($v1,$v2,$v3,$v4) = split $m1;
941($v1,$v2,$v3,$v4) = split $m1, $m2;
942($v1,$v2,$v3,$v4) = split $m1, $m2, $g1;
943
944$v1 = join $m1;
945$v2 = join $m1, $m2;
946$v3 = join $m1, $m2, $m3;
947EXPECT
948Use of uninitialized value $_ in split at - line 5.
949Use of uninitialized value $m1 in regexp compilation at - line 6.
950Use of uninitialized value $_ in split at - line 6.
951Use of uninitialized value $m1 in regexp compilation at - line 7.
952Use of uninitialized value $m2 in split at - line 7.
953Use of uninitialized value $m1 in regexp compilation at - line 8.
954Use of uninitialized value $g1 in split at - line 8.
955Use of uninitialized value $m2 in split at - line 8.
956Use of uninitialized value $m1 in join or string at - line 10.
957Use of uninitialized value $m1 in join or string at - line 11.
958Use of uninitialized value $m2 in join or string at - line 11.
959Use of uninitialized value $m1 in join or string at - line 12.
960Use of uninitialized value $m2 in join or string at - line 12.
961Use of uninitialized value $m3 in join or string at - line 12.
962########
963use warnings 'uninitialized';
964my ($m1, $m2, @ma, $v);
965
966our @foo1=(1,undef); chomp @foo1;
967my @foo2=(1,undef); chomp @foo2;
968our @foo3=(1,undef); chop @foo3;
969my @foo4=(1,undef); chop @foo4;
970our @foo5=(1,undef); $v = sprintf "%s%s",@foo5;
971my @foo6=(1,undef); $v = sprintf "%s%s",@foo6;
972our %foo7=('foo'=>'bar','baz'=>undef); $v = sprintf "%s%s",%foo7;
973my %foo8=('foo'=>'bar','baz'=>undef); $v = sprintf "%s%s",%foo8;
974our @foo9 =(1,undef); $v = sprintf "%s%s%s%s",$m1,@foo9, $ma[2];
975my @foo10=(1,undef); $v = sprintf "%s%s%s%s",$m2,@foo10,$ma[2];
976our %foo11=('foo'=>'bar','baz'=>undef); $v = join '', %foo11;
977my %foo12=('foo'=>'bar','baz'=>undef); $v = join '', %foo12;
978our %foo13=(1..2000,'foo'=>'bar','baz'=>undef); $v = join '', %foo13;
979my %foo14=(1..2000,'foo'=>'bar','baz'=>undef); $v = join '', %foo14;
980EXPECT
981Use of uninitialized value $foo1[1] in chomp at - line 4.
982Use of uninitialized value $foo2[1] in chomp at - line 5.
983Use of uninitialized value $foo3[1] in chop at - line 6.
984Use of uninitialized value $foo4[1] in chop at - line 7.
985Use of uninitialized value $foo5[1] in sprintf at - line 8.
986Use of uninitialized value $foo6[1] in sprintf at - line 9.
987Use of uninitialized value $foo7{"baz"} in sprintf at - line 10.
988Use of uninitialized value $foo8{"baz"} in sprintf at - line 11.
989Use of uninitialized value $m1 in sprintf at - line 12.
990Use of uninitialized value $foo9[1] in sprintf at - line 12.
991Use of uninitialized value in sprintf at - line 12.
992Use of uninitialized value $m2 in sprintf at - line 13.
993Use of uninitialized value $foo10[1] in sprintf at - line 13.
994Use of uninitialized value in sprintf at - line 13.
995Use of uninitialized value $foo11{"baz"} in join or string at - line 14.
996Use of uninitialized value $foo12{"baz"} in join or string at - line 15.
997Use of uninitialized value within %foo13 in join or string at - line 16.
998Use of uninitialized value within %foo14 in join or string at - line 17.
999########
1000use warnings 'uninitialized';
1001my ($v);
1002
1003undef $^A; $v = $^A + ${^FOO}; # should output '^A' not chr(1)
1004*GLOB1 = *GLOB2;
1005$v = $GLOB1 + 1;
1006$v = $GLOB2 + 1;
1007EXPECT
1008Use of uninitialized value $^FOO in addition (+) at - line 4.
1009Use of uninitialized value $^A in addition (+) at - line 4.
1010Use of uninitialized value $GLOB1 in addition (+) at - line 6.
1011Use of uninitialized value $GLOB2 in addition (+) at - line 7.
1012########
1013use warnings 'uninitialized';
1014my ($v);
1015
1016# check hash key is sanitised
1017my %h = ("\0011\002\r\n\t\f\"\\abcdefghijklmnopqrstuvwxyz", undef);
1018$v = join '', %h;
1019EXPECT
1020Use of uninitialized value $h{"\0011\2\r\n\t\f\"\\abcdefghijkl"...} in join or string at - line 6.
1021########
1022use warnings 'uninitialized';
1023my ($m1, $v);
1024our ($g1);
1025
1026$v = eval { \&$m1 };
1027$v = eval { \&$g1 };
1028
1029my @a;
1030@a = splice @a, $m1, $g1;
1031$v = 1 + splice @a, $m1, $g1;
1032
1033my $x = bless [], 'Z';
1034eval { $x->$m1() };
1035
1036eval { &$m1() };
1037eval { &$g1() };
1038
1039warn $m1,$g1,"foo";
1040
1041eval { die $m1, $g1 };
1042
1043reset $m1;
1044reset $g1;
1045EXPECT
1046Use of uninitialized value $m1 in subroutine dereference at - line 5.
1047Use of uninitialized value $m1 in subroutine dereference at - line 5.
1048Use of uninitialized value $g1 in subroutine dereference at - line 6.
1049Use of uninitialized value $g1 in subroutine dereference at - line 6.
1050Use of uninitialized value $m1 in splice at - line 9.
1051Use of uninitialized value $g1 in splice at - line 9.
1052Use of uninitialized value $m1 in splice at - line 10.
1053Use of uninitialized value $g1 in splice at - line 10.
1054Use of uninitialized value in addition (+) at - line 10.
1055Use of uninitialized value $m1 in method lookup at - line 13.
1056Use of uninitialized value $m1 in subroutine entry at - line 15.
1057Use of uninitialized value $g1 in subroutine entry at - line 16.
1058Use of uninitialized value $m1 in warn at - line 18.
1059Use of uninitialized value $g1 in warn at - line 18.
1060foo at - line 18.
1061Use of uninitialized value $m1 in die at - line 20.
1062Use of uninitialized value $g1 in die at - line 20.
1063Use of uninitialized value $m1 in symbol reset at - line 22.
1064Use of uninitialized value $g1 in symbol reset at - line 23.
1065########
1066use warnings 'uninitialized';
1067my ($m1);
1068our ($g1);
1069
1070open FOO; # accesses $FOO
1071my $foo = 'FO';
1072open($foo."O"); # accesses $FOO
1073open my $x; # accesses ${*$x}
1074open $foobar; # accesses ${*$foobar}
1075my $y;
1076open $y, $m1;
1077eval { open $y, $m1, $g1 };
1078open $y, '<', $g1;
1079
1080sysopen $y, $m1, $m2;
1081sysopen $y, $m1, $g1, $m2;
1082
1083my $old = umask;
1084umask $m1;
1085umask $g1;
1086umask $old;
1087
1088binmode STDIN, $m1;
1089EXPECT
1090Use of uninitialized value $FOO in open at - line 5.
1091Use of uninitialized value in open at - line 7.
1092Use of uninitialized value in open at - line 8.
1093Use of uninitialized value in open at - line 9.
1094Use of uninitialized value $m1 in open at - line 11.
1095Use of uninitialized value $m1 in open at - line 12.
1096Use of uninitialized value $g1 in open at - line 13.
1097Use of uninitialized value $m2 in sysopen at - line 15.
1098Use of uninitialized value $m1 in sysopen at - line 15.
1099Use of uninitialized value $m2 in sysopen at - line 16.
1100Use of uninitialized value $g1 in sysopen at - line 16.
1101Use of uninitialized value $m1 in sysopen at - line 16.
1102Use of uninitialized value $m1 in umask at - line 19.
1103Use of uninitialized value $g1 in umask at - line 20.
1104Use of uninitialized value $m1 in binmode at - line 23.
1105Use of uninitialized value $m1 in binmode at - line 23.
1106########
1107use warnings 'uninitialized';
1108my ($m1);
1109our ($g1);
1110
1111eval { my $x; tie $x, $m1 };
1112
1113eval { my $x; read $m1, $x, $g1 };
1114eval { my $x; read $m1, $x, $g1, $g2 };
1115eval { my $x; sysread $m1, $x, $g1 };
1116eval { my $x; sysread $m1, $x, $g1, $g2 };
1117EXPECT
1118Use of uninitialized value $m1 in tie at - line 5.
1119Use of uninitialized value $m1 in tie at - line 5.
1120Use of uninitialized value $m1 in ref-to-glob cast at - line 7.
1121Use of uninitialized value $g1 in read at - line 7.
1122Use of uninitialized value $m1 in ref-to-glob cast at - line 8.
1123Use of uninitialized value $g1 in read at - line 8.
1124Use of uninitialized value $g2 in read at - line 8.
1125Use of uninitialized value $m1 in ref-to-glob cast at - line 9.
1126Use of uninitialized value $g1 in sysread at - line 9.
1127Use of uninitialized value $m1 in ref-to-glob cast at - line 10.
1128Use of uninitialized value $g1 in sysread at - line 10.
1129Use of uninitialized value $g2 in sysread at - line 10.
1130########
1131use warnings 'uninitialized';
1132my ($m1);
1133our ($g1, @ga);
1134
1135printf $m1;
1136printf STDERR "%d%d%d%d\n", $m1, $m2, $g1, $g2;
1137printf $ga[1000];
1138printf STDERR "FOO1:%s\n", $ga[1000];
1139printf STDERR "FOO2:%s%s%s%s\n", $m1, $g1, $ga[1],$m2;
1140printf STDERR "FOO3:%s%s%s\n", "X", $ga[1],"Y";
1141EXPECT
1142Use of uninitialized value $m1 in printf at - line 5.
1143Use of uninitialized value $m1 in printf at - line 6.
1144Use of uninitialized value $m2 in printf at - line 6.
1145Use of uninitialized value $g1 in printf at - line 6.
1146Use of uninitialized value $g2 in printf at - line 6.
11470000
1148Use of uninitialized value $ga[1000] in printf at - line 7.
1149Use of uninitialized value $ga[1000] in printf at - line 8.
1150FOO1:
1151Use of uninitialized value $m1 in printf at - line 9.
1152Use of uninitialized value $g1 in printf at - line 9.
1153Use of uninitialized value in printf at - line 9.
1154Use of uninitialized value $m2 in printf at - line 9.
1155FOO2:
1156Use of uninitialized value $ga[1] in printf at - line 10.
1157FOO3:XY
1158########
1159use warnings 'uninitialized';
1160my ($m1);
1161our ($g1);
1162
1163eval { my $x; seek $x,$m1, $g1 };
1164eval { my $x; sysseek $x,$m1, $g1 };
1165eval { syswrite $m1, $g1 };
96d52181
DM
1166# eval { syswrite STDERR, $m1 }; # XXX under utf8, can give
1167# eval { syswrite STDERR, $m1, $g1 }; # XXX different warnings
1168# eval { syswrite STDERR, $m1, $g1, $m2 };
29489e7c
DM
1169eval { my $x; flock $x, $g1 };
1170eval { my $x; socket $x, $m1, $g1, $m2 };
1171eval { my ($x,$y); socketpair $x, $y, $m1, $g1, $m2 };
1172EXPECT
1173Use of uninitialized value $x in ref-to-glob cast at - line 5.
1174Use of uninitialized value $g1 in seek at - line 5.
1175Use of uninitialized value $m1 in seek at - line 5.
1176Use of uninitialized value $x in ref-to-glob cast at - line 6.
1177Use of uninitialized value $g1 in sysseek at - line 6.
1178Use of uninitialized value $m1 in sysseek at - line 6.
1179Use of uninitialized value $m1 in ref-to-glob cast at - line 7.
1180Use of uninitialized value $g1 in syswrite at - line 7.
29489e7c
DM
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;
96d52181 1222# $v = -k $m1; # XXX this is a no-op under win32
29489e7c
DM
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.
29489e7c
DM
1255Use of uninitialized value $m1 in -t at - line 34.
1256Use of uninitialized value $m1 in -T at - line 35.
1257Use of uninitialized value $m1 in -B at - line 36.
1258########
1259use warnings 'uninitialized';
1260my ($m1, $v);
1261our ($g1);
1262
1263$v = localtime $m1;
1264$v = gmtime $g1;
1265EXPECT
1266Use of uninitialized value $m1 in localtime at - line 5.
1267Use of uninitialized value $g1 in gmtime at - line 6.
1268########
1269use warnings 'uninitialized';
1270my ($m1, $v);
1271
1272$v = eval;
1273$v = eval $m1;
1274EXPECT
1275Use of uninitialized value $_ in eval "string" at - line 4.
1276Use of uninitialized value $_ in eval "string" at - line 4.
1277Use of uninitialized value $_ in eval "string" at - line 4.
1278Use of uninitialized value $m1 in eval "string" at - line 5.
1279Use of uninitialized value $m1 in eval "string" at - line 5.
1280Use of uninitialized value $m1 in eval "string" at - line 5.
1281########
1282use warnings 'uninitialized';
1283my ($m1);
1284
1285exit $m1;
1286EXPECT
1287Use of uninitialized value $m1 in exit at - line 4.