Subject: | Bug when retrieving values from reassigned struct |
Date: | Fri, 17 Oct 2014 22:53:53 +0200 |
To: | bug-Inline-Struct [...] rt.cpan.org |
From: | Heinz Knutzen <heinz.knutzen [...] gmail.com> |
This test case
============================================
use strict;
use warnings;
use Test::More;
use Inline C => <<'END', structs => 1, force_build => 1,
clean_after_build => 0;
struct Foo {
SV *src;
SV *dst;
char *prt;
};
END
my $o = Inline::Struct::Foo->new();
my $str = 'a';
$o->src($str)->dst($str)->prt($str);
my %vals = (src => $str, dst => $str, prt => $str);
is_deeply $o->$_(), $vals{$_}, $_ for qw(src dst prt);
my $copy = $o;
is_deeply $copy->$_(), $vals{$_}, $_ for qw(src dst prt);
done_testing;
============================================
fails with
not ok 5 - dst
# Failed test 'dst'
# at inline-struct-free-unrefd.pl line 20.
# got: '0'
# expected: 'a'
not ok 6 - prt
# Failed test 'prt'
# at inline-struct-free-unrefd.pl line 20.
# got: '`�E__'
# expected: 'a'
and it prints
"Attempt to free unreferenced scalar: SV 0x98c0538."
on exit.
Used versions:
- Inline-Struct-0.12
- Perl v5.18.2