This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add a new warning "Negative repeat count"
[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 ref-to-glob cast        [pp_rv2gv()]
10         *b = *{ undef()}
11
12   Use of uninitialized value in scalar dereference      [pp_rv2sv()]
13         my $a = undef ; my $b = $$a
14
15   Odd number of elements in hash list
16         my $a = { 1,2,3 } ;
17
18   Explicit blessing to '' (assuming package main)
19         bless \[], "";
20
21   Constant subroutine %s undefined
22         sub foo () { 1 }; undef &foo;
23
24   Constant subroutine (anonymous) undefined
25         $foo = sub () { 3 }; undef &$foo;
26
27 __END__
28 # pp.c
29 use warnings 'substr' ;
30 $a = "ab" ; 
31 $b = substr($a, 4,5) ;
32 no warnings 'substr' ;
33 $a = "ab" ; 
34 $b = substr($a, 4,5)  ;
35 EXPECT
36 substr outside of string at - line 4.
37 ########
38 # pp.c
39 use warnings 'substr' ;
40 $a = "ab" ; 
41 $b = \$a ;  
42 substr($b, 1,1) = "ab" ;
43 no warnings 'substr' ;
44 substr($b, 1,1) = "ab" ;
45 EXPECT
46 Attempt to use reference as lvalue in substr at - line 5.
47 ########
48 # pp.c
49 use warnings 'uninitialized' ;
50 *x = *{ undef() };
51 no warnings 'uninitialized' ;
52 *y = *{ undef() };
53 EXPECT
54 Use of uninitialized value in ref-to-glob cast at - line 3.
55 ########
56 # pp.c
57 use warnings 'uninitialized';
58 $x = undef; $y = $$x;
59 no warnings 'uninitialized' ;
60 $u = undef; $v = $$u;
61 EXPECT
62 Use of uninitialized value in scalar dereference at - line 3.
63 ########
64 # pp.c
65 use warnings 'misc' ;
66 my $a = { 1,2,3};
67 no warnings 'misc' ;
68 my $b = { 1,2,3};
69 EXPECT
70 Odd number of elements in anonymous hash at - line 3.
71 ########
72 # pp.c
73 use warnings 'misc' ;
74 bless \[], "" ;
75 no warnings 'misc' ;
76 bless \[], "" ;
77 EXPECT
78 Explicit blessing to '' (assuming package main) at - line 3.
79 ########
80 # pp.c
81 use warnings 'misc';
82 sub foo () { 1 }
83 undef &foo;
84 no warnings 'misc';
85 sub bar () { 2 }
86 undef &bar;
87 EXPECT
88 Constant subroutine foo undefined at - line 4.
89 ########
90 # pp.c
91 use warnings 'misc';
92 $foo = sub () { 3 };
93 undef &$foo;
94 no warnings 'misc';
95 $bar = sub () { 4 };
96 undef &$bar;
97 EXPECT
98 Constant subroutine (anonymous) undefined at - line 4.
99 ########
100 # pp.c
101 use utf8 ;
102 $_ = "\x80  \xff" ;
103 reverse ;
104 EXPECT
105 ########
106 # pp.c
107 use warnings;
108 $a = "b" x -1;
109 $a = "b" x 0;
110 no warnings;
111 $a = "b" x -1;
112 EXPECT
113 Negative repeat count at - line 3.