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