xref: /openbsd/gnu/usr.bin/perl/t/lib/warnings/pp (revision cecf84d4)
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" ;
40$b = \$a;
41substr($b, 1,1) = "\x{100}" ;
42no warnings 'substr' ;
43$b = \$a;
44substr($b, 1,1) = "ab" ;
45$b = \$a;
46substr($b, 1,1) = "\x{100}" ;
47EXPECT
48Attempt to use reference as lvalue in substr at - line 5.
49Attempt to use reference as lvalue in substr at - line 7.
50########
51# pp.c
52use warnings 'misc' ;
53@a = qw( a b c );
54splice(@a, 4, 0, 'e') ;
55@a = qw( a b c );
56splice(@a, 4, 1) ;
57@a = qw( a b c );
58splice(@a, 4) ;
59no warnings 'misc' ;
60@a = qw( a b c );
61splice(@a, 4, 0, 'e') ;
62@a = qw( a b c );
63splice(@a, 4, 1) ;
64@a = qw( a b c );
65splice(@a, 4) ;
66EXPECT
67splice() offset past end of array at - line 4.
68splice() offset past end of array at - line 6.
69########
70# pp.c
71use warnings 'uninitialized';
72$x = undef; $y = $$x;
73no warnings 'uninitialized' ;
74$u = undef; $v = $$u;
75EXPECT
76Use of uninitialized value $x in scalar dereference at - line 3.
77########
78# pp.c
79use warnings 'misc' ;
80my $a = { 1,2,3};
81no warnings 'misc' ;
82my $b = { 1,2,3};
83EXPECT
84Odd number of elements in anonymous hash at - line 3.
85########
86# pp.c
87use warnings 'misc' ;
88bless \[], "" ;
89no warnings 'misc' ;
90bless \[], "" ;
91EXPECT
92Explicit blessing to '' (assuming package main) at - line 3.
93########
94# pp.c
95use warnings 'misc';
96sub foo () { 1 }
97undef &foo;
98no warnings 'misc';
99sub bar () { 2 }
100undef &bar;
101EXPECT
102Constant subroutine foo undefined at - line 4.
103########
104# pp.c
105use utf8;
106use open qw( :utf8 :std );
107use warnings 'misc';
108sub ฝᶱ () { 1 }
109undef &ฝᶱ;
110no warnings 'misc';
111sub ƚ () { 2 }
112undef &ƚ;
113EXPECT
114Constant subroutine ฝᶱ undefined at - line 6.
115########
116# pp.c
117use warnings 'misc';
118$foo = sub () { 3 };
119undef &$foo;
120no warnings 'misc';
121$bar = sub () { 4 };
122undef &$bar;
123EXPECT
124Constant subroutine (anonymous) undefined at - line 4.
125########
126# pp.c
127use utf8 ;
128$_ = "\x80  \xff" ;
129reverse ;
130EXPECT
131