nayakgi / perl-compiler

Automatically exported from code.google.com/p/perl-compiler
Other
0 stars 0 forks source link

bytes::length is incorrect from a compiled code #255

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. compile and run the following script

> cat script.pl

$a = chr(300);
my $l = length($a);
my $lb;
{ use bytes; $lb = length($a); }
print( ( $l == 1 && $lb == 2 ) ? "ok\n" : "l -> $l ; lb -> $lb\n" );

__END__

What is the expected output ? 

> perl script.pl
ok

What do you see instead?

> for i in `seq 0 3`; do perlcc -O$i script.pl && ./script; done
l -> 1 ; lb -> 1
l -> 1 ; lb -> 1
l -> 1 ; lb -> 1
l -> 1 ; lb -> 1

Please use labels and text to provide additional information.

note that if bytes is lazyloaded then it works
eval q{ use bytes; $lb = length($a) };

Original issue reported on code.google.com by nicolas....@gmail.com on 3 Dec 2013 at 5:02

GoogleCodeExporter commented 9 years ago

Original comment by reini.urban on 3 Dec 2013 at 5:54