perlcc: array becomes NULL if Visual Studio used for compilation
Opened this issue · 1 comments
rurban commented
How to reproduce:
use Data::Dumper;
my $test;
$test = sub {
my @arr;
print Dumper \@arr;
return defined $test; # disables optimization?
};
$test->();
Compiled with perlcc --Wl="vcruntime.lib" test.pl
.
Linux and Mingw-w64 versions of perlcc produce binary that prints $VAR1 = [];
as interpreter does.
But if binary compiled with Visual Studio it prints $VAR1 = \undef;
and causes null pointer exception on array operations.
constantined commented
Maybe diff of Devel::Peek outputs will be helpful:
--- test-nobug.txt
+++ test-bug.txt
@@ -11,9 +11,10 @@
GVGV::GV = <NUMBER> "main" :: "__ANON__"
FILE = "test.pl"
DEPTH = 0
- CVFLAGS = 0x1490 (ANON,WEAKOUTSIDE,CVGV_RC,DYNFILE)
+ CVFLAGS = 0x14c0 (ANON,CLONED,CVGV_RC,DYNFILE)
OUTSIDE_SEQ = 119
PADLIST = <NUMBER> [1]
PADNAME = <NUMBER>(<NUMBER>) PAD = <NUMBER>(<NUMBER>)
1. <NUMBER><1> (120,121) "@arr"
- OUTSIDE = 0x3626a0 (MAIN)
+ 2. 0x534720<2> FAKE "$test" flags=0x0 index=1
+ OUTSIDE = 0x0 (null)
nobug
is the same code, but without the return defined $test;
line.
Output of cperl -DXv test.pl
:
Pad CV clone
Proto: CV=0x282910 (ANON), OUTSIDE=0x2526f8 (MAIN)
PADLIST = 0x296170
PADNAME = 0x295270(0x296300) PAD = 0x290f80(0x2962b0)
1. 0x0<0> (4294967248,4294967249) "@arr"
2. 0x0<0> FAKE "$test" flags=0x0 index=1
To: CV=0x252548 (ANON), OUTSIDE=0x0 (null)
PADLIST = 0x244820
PADNAME = 0x295270(0x296300) PAD = 0x252650(0x295f90)
1. 0x2526b0<1> (4294967248,4294967249) "@arr"
2. 0x282418<2> FAKE "$test" flags=0x0 index=1