blob: fc1e6dde3f446204e0cd86c283f84c9cac24824f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
util.c AOK
Illegal octal digit ignored
my $a = oct "029" ;
Illegal hex digit ignored
my $a = hex "0xv9" ;
Illegal binary digit ignored
my $a = oct "0b9" ;
Mandatory Warnings
------------------
Integer overflow in binary number
Integer overflow in octal number
Integer overflow in hex number
__END__
# util.c
use warning 'octal' ;
my $a = oct "029" ;
no warning 'octal' ;
my $a = oct "029" ;
EXPECT
Illegal octal digit '9' ignored at - line 3.
########
# util.c
use warning 'unsafe' ;
*a = hex "0xv9" ;
no warning 'unsafe' ;
*a = hex "0xv9" ;
EXPECT
Illegal hexadecimal digit 'v' ignored at - line 3.
########
# util.c
use warning 'unsafe' ;
*a = oct "0b9" ;
no warning 'unsafe' ;
*a = oct "0b9" ;
EXPECT
Illegal binary digit '9' ignored at - line 3.
########
# util.c
BEGIN { require Config ; import Config }
$^W =1 ;
sub make_bin { "1" x $_[0] }
my $s = $Config{longsize};
eval { pack "q", 0 }; eval { $s = length pack "q", 0 } unless $@;
$n = make_bin(8 * $s ) ;
$o = make_bin(8 * $s + 1) ;
{
use warning 'unsafe' ;
my $a = oct "0b$n" ;
my $b = oct "0b$o" ;
no warning 'unsafe' ;
$b = oct "0b$o" ;
}
my $b = oct "0b$o" ;
EXPECT
Integer overflow in binary number at - line 12.
Integer overflow in binary number at - line 16.
########
# util.c
BEGIN { require Config ; import Config }
$^W =1 ;
sub make_oct { ("","1","3")[$_[0]%3] . "7" x int($_[0]/3) }
my $s = $Config{longsize};
eval { pack "q", 0 }; eval { $s = length pack "q", 0 } unless $@;
$n = make_oct(8 * $s );
$o = make_oct(8 * $s + 1);
{
use warning 'unsafe' ;
my $a = oct "$n" ;
my $b = oct "$o" ;
no warning 'unsafe' ;
$b = oct "$o" ;
}
my $b = oct "$o" ;
EXPECT
Integer overflow in octal number at - line 12.
Integer overflow in octal number at - line 16.
########
# util.c
BEGIN { require Config ; import Config }
$^W =1 ;
sub make_hex { ("","1","3","7")[$_[0]%4] . "f" x int($_[0]/4) }
my $s = $Config{longsize};
eval { pack "q", 0 }; eval { $s = length pack "q", 0 } unless $@;
$n = make_hex(8 * $s ) ;
$o = make_hex(8 * $s + 1) ;
{
use warning 'unsafe' ;
my $a = hex "$n" ;
my $b = hex "$o" ;
no warning 'unsafe' ;
$b = hex "$o" ;
}
my $b = hex "$o" ;
EXPECT
Integer overflow in hexadecimal number at - line 12.
Integer overflow in hexadecimal number at - line 16.
|