Open p6rt opened 8 years ago
See the following result
$ perl6 -MNativeCall -e 'my $null = Pointer; my $not-null = CArray[int32].new; $not-null[0] = 1; $not-null[1] = 1; $not-null[2] = 1; say nativesizeof($not-null)' 8
I think that it should return 12, since the following equivalent C code returns 12.
--
#include \<stdio.h>
int main() { int a[3]; a[0] = 1; a[1] = 1; a[2] = 1; printf("sizeof a: %d\n", sizeof(a)); // sizeof a: 12 }
--
$ gcc --version gcc (Debian 4.9.2-10) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ perl6 --version This is Rakudo version 2016.07.1-199-gdd9b760 built on MoarVM version 2016.07-17-g40948f6 implementing Perl 6.c.
On Sat, Sep 10, 2016 at 10:11 AM, Itsuki Toyota \< perl6-bugs-followup@perl.org> wrote:
$ perl6 -MNativeCall -e 'my $null = Pointer; my $not-null = CArray[int32].new; $not-null[0] = 1; $not-null[1] = 1; $not-null[2] = 1; say nativesizeof($not-null)' 8
That size looks doubly wrong to me. Its not going to happen for a 3-element array no matter how you slice it... so I suspect you're getting the size of one element, which is itself twice the size of what C thinks.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
The RT System itself - Status changed from 'new' to 'open'
You get 8 there because an array is a pointerish thing...
Btw, this: my $not-null = CArray[int32].new is not the same as this: int a[3];
So, we would need fixed sized native arrays here to tell the truth.
Am 10.09.2016 um 20:53 schrieb Brandon Allbery via RT:
On Sat, Sep 10, 2016 at 10:11 AM, Itsuki Toyota \< perl6-bugs-followup@perl.org> wrote:
$ perl6 -MNativeCall -e 'my $null = Pointer; my $not-null = CArray[int32].new; $not-null[0] = 1; $not-null[1] = 1; $not-null[2] = 1; say nativesizeof($not-null)' 8
That size looks doubly wrong to me. Its not going to happen for a 3-element array no matter how you slice it... so I suspect you're getting the size of one element, which is itself twice the size of what C thinks.
Migrated from rt.perl.org#129240 (status was 'open')
Searchable as RT129240$