New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistency between NULL CPointer behavior jvm vs moar #3765
Comments
From @skidsPointer-based classes are behaving differently on moar and jvm: (03/30/2015 10:49:07 PM) skids: r: use NativeCall; sub strstr(Str $n, Str $c) returns OpaquePointer is native { } ; my $d = strstr("c","aaa"); $d.say; $d.defined.say; This has broken previously-working assumptions about CPointer-based classes on JVM. Since CPointer type objects passed to native functions cause a NULL pointer If there is also a use case for a pointer class that is .defined when NULL, there This patch gets you halfway to tests, once the correct behavior is decided. Inline Patchdiff --git a/t/04-nativecall/04-pointers.c b/t/04-nativecall/04-pointers.c
index 0b617c6..230515a 100644
--- a/t/04-nativecall/04-pointers.c
+++ b/t/04-nativecall/04-pointers.c
@@ -18,3 +18,13 @@ DLLEXPORT int CompareSomePointer(void *ptr)
int x = strcmp("Got passed back the pointer I returned", ptr) == 0;
return x;
}
+
+DLLEXPORT void * ReturnNullPointer()
+{
+ return NULL;
+}
+
+DLLEXPORT void * ReturnNullOpaquePointer()
+{
+ return NULL;
+}
diff --git a/t/04-nativecall/04-pointers.t b/t/04-nativecall/04-pointers.t
index 0bdad20..1b1b59c 100644
--- a/t/04-nativecall/04-pointers.t
+++ b/t/04-nativecall/04-pointers.t
@@ -10,6 +10,9 @@ compile_test_lib('04-pointers');
sub ReturnSomePointer() returns Pointer is native("./04-pointers") { * }
sub CompareSomePointer(Pointer) returns int32 is native("./04-pointers") { * }
+sub ReturnNullPointer() returns Pointer is native("./04-pointers") { * }
+sub ReturnNullOpaquePointer() returns OpaquePointer is native("./04-pointers") { * }
+
my $x = ReturnSomePointer();
my int $a = 4321;
@@ -23,4 +26,9 @@ is Pointer.new.gist, 'Pointer<NULL>', 'Pointer.new gistifies to "Pointer
is Pointer.new(0).gist, 'Pointer<NULL>', 'Pointer.new(0) gistifies to "Pointer<NULL>"';
is Pointer.new(1234).gist, 'Pointer<0x4d2>', 'Pointer.new(1234) gistifies to "Pointer<0x4d2>"';
is Pointer.new($a).gist, 'Pointer<0x10e1>', 'Pointer.new accepts a native int too';
-is Pointer.gist, '(Pointer)', 'The Pointer type object gistifies ot "Pointer"';
+is Pointer.gist, '(Pointer)', 'The Pointer type object gistifies to "Pointer"';
+
+ReturnNullPointer.say;
+ReturnNullOpaquePointer.say;
+ReturnNullPointer.defined.say;
+ReturnNullOpaquePointer.defined.say; |
From @FROGGSThe jvm got aligned to moar in: Raku/nqp@0ccec451ed |
|
@FROGGS - Status changed from 'new' to 'resolved' |
From @FROGGSTests: rakudo/rakudo@76ba0a26e3 |
Migrated from rt.perl.org#124214 (status was 'resolved')
Searchable as RT124214$
The text was updated successfully, but these errors were encountered: