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