Opened 3 years ago

Closed 3 years ago

#1424 closed defect (fixed)

(const c-string) as result type breaks with NULL

Reported by: wasamasa Owned by:
Priority: minor Milestone: 4.13.0
Component: compiler Version: 4.11.0
Keywords: foreign Cc:
Estimated difficulty:


I'm writing bindings to a library which uses const on both string argument and return types. If I declare a foreign function returning NULL to have (const c-string) as return type, I get a segmentation violation, c-string as return type however returns #f as expected.

Minimal repro:

(import chicken scheme foreign)

#> static const char* test() { return NULL; } <#

(define test (foreign-lambda c-string "test"))
(define test2 (foreign-lambda (const c-string) "test"))

(test) ;=> #f
(test2) ;=> segfault

Change History (2)

comment:1 Changed 3 years ago by wasamasa

FWIW, the C4 patch resolves the issue for me. The C5 one also works as intended, before I got a "cannot compute size of location for foreign type" error.

Last edited 3 years ago by wasamasa (previous) (diff)

comment:2 Changed 3 years ago by evhan

Resolution: fixed
Status: newclosed

Fixed with a0bb345 and c3393980.

Note: See TracTickets for help on using tickets.