partly fix perldiag regressions identified by Tom Christiansen
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / pp
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
28   Constant subroutine %s undefined                      <<<TODO
29   Constant subroutine (anonymous) undefined             <<<TODO
30
31   Mandatory Warnings
32   ------------------
33   Malformed UTF-8 character
34
35 __END__
36 # pp.c
37 use warnings 'substr' ;
38 $a = "ab" ; 
39 $a = substr($a, 4,5);
40 no warnings 'substr' ;
41 $a = "ab" ; 
42 $a = substr($a, 4,5);
43 EXPECT
44 substr outside of string at - line 4.
45 ########
46 # pp.c
47 use warnings 'substr' ;
48 $a = "ab" ; 
49 $b = \$a ;  
50 substr($b, 1,1) = "ab" ;
51 no warnings 'substr' ;
52 substr($b, 1,1) = "ab" ;
53 EXPECT
54 Attempt to use reference as lvalue in substr at - line 5.
55 ########
56 # pp.c
57 use warnings 'uninitialized' ;
58 # TODO
59 EXPECT
60
61 ########
62 # pp.c
63 use warnings 'unsafe' ;
64 my $a = { 1,2,3};
65 no warnings 'unsafe' ;
66 my $b = { 1,2,3};
67 EXPECT
68 Odd number of elements in hash assignment at - line 3.
69 ########
70 # pp.c
71 use warnings 'unsafe' ;
72 my @a = unpack ("A,A", "22") ;
73 my $a = pack ("A,A", 1,2) ;
74 no warnings 'unsafe' ;
75 my @b = unpack ("A,A", "22") ;
76 my $b = pack ("A,A", 1,2) ;
77 EXPECT
78 Invalid type in unpack: ',' at - line 3.
79 Invalid type in pack: ',' at - line 4.
80 ########
81 # pp.c
82 use warnings 'uninitialized' ;
83 my $a = undef ; 
84 my $b = $$a;
85 no warnings 'uninitialized' ;
86 my $c = $$a;
87 EXPECT
88 Use of uninitialized value in scalar dereference at - line 4.
89 ########
90 # pp.c
91 use warnings 'unsafe' ;
92 sub foo { my $a = "a"; return $a . $a++ . $a++ }
93 my $a = pack("p", &foo) ;
94 no warnings 'unsafe' ;
95 my $b = pack("p", &foo) ;
96 EXPECT
97 Attempt to pack pointer to temporary value at - line 4.
98 ########
99 # pp.c
100 use warnings 'unsafe' ;
101 bless \[], "" ;
102 no warnings 'unsafe' ;
103 bless \[], "" ;
104 EXPECT
105 Explicit blessing to '' (assuming package main) at - line 3.
106 ########
107 # pp.c
108 use utf8 ;
109 $_ = "\x80  \xff" ;
110 reverse ;
111 EXPECT
112 Malformed UTF-8 character at - line 4.
113 ########
114 # pp.c
115 use warnings 'utf8'  ;
116 use utf8 ;
117 $_ = "\x80  \xff" ;
118 reverse ;
119 no warnings 'utf8'  ;
120 $_ = "\x80  \xff" ;
121 reverse ;
122 EXPECT
123 \x80 will produce malformed UTF-8 character; use \x{80} for that at - line 4.
124 \xff will produce malformed UTF-8 character; use \x{ff} for that at - line 4.
125 Malformed UTF-8 character at - line 5.