4c70fd5d6f5a1f69be6e06fea5e8b8bbbc2f2838
[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 (not tested: difficult to produce with
34                              perl now)
35
36 __END__
37 # pp.c
38 use warnings 'substr' ;
39 $a = "ab" ; 
40 $a = substr($a, 4,5);
41 no warnings 'substr' ;
42 $a = "ab" ; 
43 $a = substr($a, 4,5);
44 EXPECT
45 substr outside of string at - line 4.
46 ########
47 # pp.c
48 use warnings 'substr' ;
49 $a = "ab" ; 
50 $b = \$a ;  
51 substr($b, 1,1) = "ab" ;
52 no warnings 'substr' ;
53 substr($b, 1,1) = "ab" ;
54 EXPECT
55 Attempt to use reference as lvalue in substr at - line 5.
56 ########
57 # pp.c
58 use warnings 'uninitialized' ;
59 # TODO
60 EXPECT
61
62 ########
63 # pp.c
64 use warnings 'unsafe' ;
65 my $a = { 1,2,3};
66 no warnings 'unsafe' ;
67 my $b = { 1,2,3};
68 EXPECT
69 Odd number of elements in hash assignment at - line 3.
70 ########
71 # pp.c
72 use warnings 'unsafe' ;
73 my @a = unpack ("A,A", "22") ;
74 my $a = pack ("A,A", 1,2) ;
75 no warnings 'unsafe' ;
76 my @b = unpack ("A,A", "22") ;
77 my $b = pack ("A,A", 1,2) ;
78 EXPECT
79 Invalid type in unpack: ',' at - line 3.
80 Invalid type in pack: ',' at - line 4.
81 ########
82 # pp.c
83 use warnings 'uninitialized' ;
84 my $a = undef ; 
85 my $b = $$a;
86 no warnings 'uninitialized' ;
87 my $c = $$a;
88 EXPECT
89 Use of uninitialized value in scalar dereference at - line 4.
90 ########
91 # pp.c
92 use warnings 'unsafe' ;
93 sub foo { my $a = "a"; return $a . $a++ . $a++ }
94 my $a = pack("p", &foo) ;
95 no warnings 'unsafe' ;
96 my $b = pack("p", &foo) ;
97 EXPECT
98 Attempt to pack pointer to temporary value at - line 4.
99 ########
100 # pp.c
101 use warnings 'unsafe' ;
102 bless \[], "" ;
103 no warnings 'unsafe' ;
104 bless \[], "" ;
105 EXPECT
106 Explicit blessing to '' (assuming package main) at - line 3.
107 ########
108 # pp.c
109 use utf8 ;
110 $_ = "\x80  \xff" ;
111 reverse ;
112 EXPECT
113 ########
114 # pp.c
115 BEGIN {
116     if (ord("\t") == 5) {
117         print "SKIPPED\n# Character codes differ on ebcdic machines.";
118         exit 0;
119     }
120 }
121 use warnings 'utf8'  ;
122 use utf8 ;
123 $_ = "\x80  \xff" ;
124 reverse ;
125 no warnings 'utf8'  ;
126 $_ = "\x80  \xff" ;
127 reverse ;
128 EXPECT
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.