B::CC fails on interpolated string assignment

5 views
Skip to first unread message

Heinz Knutzen

unread,
Aug 15, 2010, 3:27:12 PM8/15/10
to perl-c...@googlegroups.com
B::CC fails if applied to this test program.

fail1.pl:
=====
sub f {
my $v;
my $a = 1;
$v = "$a,$a";
}
=====

$ perl -MO=CC,-ofail1.c fail1.pl
Modification of non-creatable array value attempted, subscript -1 at
/usr/local/lib/perl/5.10.1/B/CC.pm line 929.
CHECK failed--call queue aborted.

But it gives a correct result if optimization level 0 or 1 is stated
explicitly:
$ perl -MO=CC,-O0,-ofail1.c fail1.pl
fail1.pl syntax OK
$ cc_harness -o fail1 fail1.c
cc -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/usr/lib/perl/5.10/CORE -o fail1 fail1.c -Wl,-E
-fstack-protector -L/usr/local/lib -L/usr/lib/perl/5.10/CORE
/usr/lib/libperl.so.5.10.1 -ldl -lm -lpthread -lc -lcrypt
fail1.c: In function ‘perl_init_aaaa’:
fail1.c:233: warning: assignment from incompatible pointer type
fail1.c:246: warning: assignment from incompatible pointer type
fail1.c:255: warning: assignment from incompatible pointer type
fail1.c:279: warning: assignment from incompatible pointer type
fail1.c:352: warning: assignment from incompatible pointer type
fail1.c:408: warning: assignment from incompatible pointer type
$ ./fail1
1,1

With optimization level 2, it compiles, but the result is wrong:
$ perl -MO=CC,-O2,-ofail1.c fail1.pl
fail1.pl syntax OK
$ cc_harness -o fail1 fail1.c
cc -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/usr/lib/perl/5.10/CORE -o fail1 fail1.c -Wl,-E
-fstack-protector -L/usr/local/lib -L/usr/lib/perl/5.10/CORE
/usr/lib/libperl.so.5.10.1 -ldl -lm -lpthread -lc -lcrypt
fail1.c: In function ‘perl_init_aaaa’:
fail1.c:233: warning: assignment from incompatible pointer type
fail1.c:246: warning: assignment from incompatible pointer type
fail1.c:255: warning: assignment from incompatible pointer type
fail1.c:279: warning: assignment from incompatible pointer type
fail1.c:352: warning: assignment from incompatible pointer type
fail1.c:408: warning: assignment from incompatible pointer type
$ ./fail1

(empty line)

Used versions:
- perl v5.10.1 (*) built for i486-linux-gnu-thread-mult
(from Ubuntu 10.04)
- B::C version 1.27

--
Heinz Knutzen

Reply all
Reply to author
Forward
0 new messages