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