xref: /openbsd-src/gnu/usr.bin/perl/t/lib/warnings/pp (revision 898184e3e61f9129feb5978fad5a8c6865f00b92)
1  pp.c	TODO
2
3  substr outside of string
4    $a = "ab" ; $b = substr($a, 4,5) ;
5
6  Attempt to use reference as lvalue in substr
7    $a = "ab" ; $b = \$a ;  substr($b, 1,1) = $b
8
9  Use of uninitialized value in scalar dereference	[pp_rv2sv()]
10	my $a = undef ; my $b = $$a
11
12  Odd number of elements in hash list
13	my $a = { 1,2,3 } ;
14
15  Explicit blessing to '' (assuming package main)
16	bless \[], "";
17
18  Constant subroutine %s undefined
19	sub foo () { 1 }; undef &foo;
20
21  Constant subroutine (anonymous) undefined
22	$foo = sub () { 3 }; undef &$foo;
23
24__END__
25# pp.c
26use warnings 'substr' ;
27$a = "ab" ;
28$b = substr($a, 4,5) ;
29no warnings 'substr' ;
30$a = "ab" ;
31$b = substr($a, 4,5)  ;
32EXPECT
33substr outside of string at - line 4.
34########
35# pp.c
36use warnings 'substr' ;
37$a = "ab" ;
38$b = \$a ;
39substr($b, 1,1) = "ab" ;
40no warnings 'substr' ;
41substr($b, 1,1) = "ab" ;
42EXPECT
43Attempt to use reference as lvalue in substr at - line 5.
44########
45# pp.c
46use warnings 'misc' ;
47@a = qw( a b c );
48splice(@a, 4, 0, 'e') ;
49@a = qw( a b c );
50splice(@a, 4, 1) ;
51@a = qw( a b c );
52splice(@a, 4) ;
53no warnings 'misc' ;
54@a = qw( a b c );
55splice(@a, 4, 0, 'e') ;
56@a = qw( a b c );
57splice(@a, 4, 1) ;
58@a = qw( a b c );
59splice(@a, 4) ;
60EXPECT
61splice() offset past end of array at - line 4.
62splice() offset past end of array at - line 6.
63########
64# pp.c
65use warnings 'uninitialized';
66$x = undef; $y = $$x;
67no warnings 'uninitialized' ;
68$u = undef; $v = $$u;
69EXPECT
70Use of uninitialized value $x in scalar dereference at - line 3.
71########
72# pp.c
73use warnings 'misc' ;
74my $a = { 1,2,3};
75no warnings 'misc' ;
76my $b = { 1,2,3};
77EXPECT
78Odd number of elements in anonymous hash at - line 3.
79########
80# pp.c
81use warnings 'misc' ;
82bless \[], "" ;
83no warnings 'misc' ;
84bless \[], "" ;
85EXPECT
86Explicit blessing to '' (assuming package main) at - line 3.
87########
88# pp.c
89use warnings 'misc';
90sub foo () { 1 }
91undef &foo;
92no warnings 'misc';
93sub bar () { 2 }
94undef &bar;
95EXPECT
96Constant subroutine foo undefined at - line 4.
97########
98# pp.c
99use utf8;
100use open qw( :utf8 :std );
101use warnings 'misc';
102sub ฝᶱ () { 1 }
103undef &ฝᶱ;
104no warnings 'misc';
105sub ƚ () { 2 }
106undef &ƚ;
107EXPECT
108Constant subroutine ฝᶱ undefined at - line 6.
109########
110# pp.c
111use warnings 'misc';
112$foo = sub () { 3 };
113undef &$foo;
114no warnings 'misc';
115$bar = sub () { 4 };
116undef &$bar;
117EXPECT
118Constant subroutine (anonymous) undefined at - line 4.
119########
120# pp.c
121use utf8 ;
122$_ = "\x80  \xff" ;
123reverse ;
124EXPECT
125