This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Quick integration of mainline changes to date
[perl5.git] / t / pragma / warn / pp
CommitLineData
599cee73
PM
1 pp.c TODO
2
3 substr outside of string
4 $a = "ab" ; $a = 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 uninitialized in pp_rv2gv()
10 my *b = *{ undef()}
11
12 uninitialized in 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 Invalid type in unpack: '%c
19 my $A = pack ("A,A", 1,2) ;
20 my @A = unpack ("A,A", "22") ;
21
22 Attempt to pack pointer to temporary value
23 pack("p", "abc") ;
24
25 Explicit blessing to '' (assuming package main)
26 bless \[], "";
27
0453d815
PM
28 Constant subroutine %s undefined <<<TODO
29 Constant subroutine (anonymous) undefined <<<TODO
30
31 Mandatory Warnings
32 ------------------
33 Malformed UTF-8 character
599cee73
PM
34
35__END__
36# pp.c
4438c4b7 37use warnings 'substr' ;
599cee73 38$a = "ab" ;
0453d815 39$a = substr($a, 4,5);
4438c4b7 40no warnings 'substr' ;
0453d815
PM
41$a = "ab" ;
42$a = substr($a, 4,5);
599cee73
PM
43EXPECT
44substr outside of string at - line 4.
45########
46# pp.c
4438c4b7 47use warnings 'substr' ;
599cee73
PM
48$a = "ab" ;
49$b = \$a ;
50substr($b, 1,1) = "ab" ;
4438c4b7 51no warnings 'substr' ;
0453d815 52substr($b, 1,1) = "ab" ;
599cee73
PM
53EXPECT
54Attempt to use reference as lvalue in substr at - line 5.
55########
56# pp.c
4438c4b7 57use warnings 'uninitialized' ;
599cee73
PM
58# TODO
59EXPECT
60
61########
62# pp.c
4438c4b7 63use warnings 'unsafe' ;
599cee73 64my $a = { 1,2,3};
4438c4b7 65no warnings 'unsafe' ;
0453d815 66my $b = { 1,2,3};
599cee73
PM
67EXPECT
68Odd number of elements in hash assignment at - line 3.
69########
70# pp.c
4438c4b7 71use warnings 'unsafe' ;
599cee73
PM
72my @a = unpack ("A,A", "22") ;
73my $a = pack ("A,A", 1,2) ;
4438c4b7 74no warnings 'unsafe' ;
0453d815
PM
75my @b = unpack ("A,A", "22") ;
76my $b = pack ("A,A", 1,2) ;
599cee73
PM
77EXPECT
78Invalid type in unpack: ',' at - line 3.
79Invalid type in pack: ',' at - line 4.
80########
81# pp.c
4438c4b7 82use warnings 'uninitialized' ;
599cee73 83my $a = undef ;
0453d815 84my $b = $$a;
4438c4b7 85no warnings 'uninitialized' ;
0453d815 86my $c = $$a;
599cee73 87EXPECT
146174a9 88Use of uninitialized value in scalar dereference at - line 4.
599cee73
PM
89########
90# pp.c
4438c4b7 91use warnings 'unsafe' ;
599cee73
PM
92sub foo { my $a = "a"; return $a . $a++ . $a++ }
93my $a = pack("p", &foo) ;
4438c4b7 94no warnings 'unsafe' ;
0453d815 95my $b = pack("p", &foo) ;
599cee73
PM
96EXPECT
97Attempt to pack pointer to temporary value at - line 4.
98########
99# pp.c
4438c4b7 100use warnings 'unsafe' ;
599cee73 101bless \[], "" ;
4438c4b7 102no warnings 'unsafe' ;
0453d815 103bless \[], "" ;
599cee73
PM
104EXPECT
105Explicit blessing to '' (assuming package main) at - line 3.
0453d815
PM
106########
107# pp.c
108use utf8 ;
109$_ = "\x80 \xff" ;
110reverse ;
111EXPECT
112Malformed UTF-8 character at - line 4.
113########
114# pp.c
146174a9
CB
115BEGIN {
116 if (ord("\t") == 5) {
117 print "SKIPPED\n# Character codes differ on ebcdic machines.";
118 exit 0;
119 }
120}
4438c4b7 121use warnings 'utf8' ;
0453d815
PM
122use utf8 ;
123$_ = "\x80 \xff" ;
124reverse ;
4438c4b7 125no warnings 'utf8' ;
0453d815
PM
126$_ = "\x80 \xff" ;
127reverse ;
128EXPECT
146174a9
CB
129\x80 will produce malformed UTF-8 character; use \x{80} for that at - line 10.
130\xff will produce malformed UTF-8 character; use \x{ff} for that at - line 10.
131Malformed UTF-8 character at - line 11.