This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Preserve 64-bit array offsets in uninit warnings
[perl5.git] / t / lib / warnings / pp
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
26 use warnings 'substr' ;
27 $a = "ab" ; 
28 $b = substr($a, 4,5) ;
29 no warnings 'substr' ;
30 $a = "ab" ; 
31 $b = substr($a, 4,5)  ;
32 EXPECT
33 substr outside of string at - line 4.
34 ########
35 # pp.c
36 use warnings 'substr' ;
37 $a = "ab" ; 
38 $b = \$a ;  
39 substr($b, 1,1) = "ab" ;
40 $b = \$a;
41 substr($b, 1,1) = "\x{100}" ;
42 no warnings 'substr' ;
43 $b = \$a;
44 substr($b, 1,1) = "ab" ;
45 $b = \$a;
46 substr($b, 1,1) = "\x{100}" ;
47 EXPECT
48 Attempt to use reference as lvalue in substr at - line 5.
49 Attempt to use reference as lvalue in substr at - line 7.
50 ########
51 # pp.c
52 use warnings 'misc' ;
53 @a = qw( a b c );
54 splice(@a, 4, 0, 'e') ;
55 @a = qw( a b c );
56 splice(@a, 4, 1) ;
57 @a = qw( a b c );
58 splice(@a, 4) ;
59 no warnings 'misc' ;
60 @a = qw( a b c );
61 splice(@a, 4, 0, 'e') ;
62 @a = qw( a b c );
63 splice(@a, 4, 1) ;
64 @a = qw( a b c );
65 splice(@a, 4) ;
66 EXPECT
67 splice() offset past end of array at - line 4.
68 splice() offset past end of array at - line 6.
69 ########
70 # pp.c
71 use warnings 'uninitialized';
72 $x = undef; $y = $$x;
73 no warnings 'uninitialized' ;
74 $u = undef; $v = $$u;
75 EXPECT
76 Use of uninitialized value $x in scalar dereference at - line 3.
77 ########
78 # pp.c
79 use warnings 'misc' ;
80 my $a = { 1,2,3};
81 no warnings 'misc' ;
82 my $b = { 1,2,3};
83 EXPECT
84 Odd number of elements in anonymous hash at - line 3.
85 ########
86 # pp.c
87 use warnings 'misc' ;
88 bless \[], "" ;
89 no warnings 'misc' ;
90 bless \[], "" ;
91 EXPECT
92 Explicit blessing to '' (assuming package main) at - line 3.
93 ########
94 # pp.c
95 use warnings 'misc';
96 sub foo () { 1 }
97 undef &foo;
98 no warnings 'misc';
99 sub bar () { 2 }
100 undef &bar;
101 EXPECT
102 Constant subroutine foo undefined at - line 4.
103 ########
104 # pp.c
105 use utf8;
106 use open qw( :utf8 :std );
107 use warnings 'misc';
108 sub ฝᶱ () { 1 }
109 undef &ฝᶱ;
110 no warnings 'misc';
111 sub ƚ () { 2 }
112 undef &ƚ;
113 EXPECT
114 Constant subroutine ฝᶱ undefined at - line 6.
115 ########
116 # pp.c
117 use warnings 'misc';
118 $foo = sub () { 3 };
119 undef &$foo;
120 no warnings 'misc';
121 $bar = sub () { 4 };
122 undef &$bar;
123 EXPECT
124 Constant subroutine (anonymous) undefined at - line 4.
125 ########
126 # pp.c
127 use utf8 ;
128 $_ = "\x80  \xff" ;
129 reverse ;
130 EXPECT
131 ########
132 # NAME deprecation of complement with above ff code points
133 $_ = ~ "\xff";
134 $_ = ~ "\x{100}";
135 EXPECT
136 OPTION regex
137 Use of strings with code points over 0xFF as arguments to 1's complement \(~\) operator is deprecated at - line \d+.
138 Use of code point 0xFF+EFF is deprecated; the permissible max is 0x7F+ at - line \d+.