Summary
(const c-string) as result type breaks with NULL
Metadata
- Id: c5a1c81a0d43faab89ed52310ebc1ee3f904e910
- Trac id: 1424
- Type: defect
- Reporter: wasamasa
- Owner:
- Cc:
- Status: closed
- Component: compiler
- Estimated difficulty:
- Resolution: fixed
- Priority: minor
- Milestone: 4.13.0
- Version: 4.11.0
- Changetime: 2017-11-11 21:59:54 UTC
- Created: 2017-11-08 15:25:11 UTC
- Keywords: foreign
Description
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
Changes and comments
[2017-11-09 14:10:10 UTC] wasamasa wrote:
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.
[2017-11-09 14:10:10 UTC] wasamasa wrote:
1510233053854813
[2017-11-09 14:10:10 UTC] wasamasa wrote:
1510234341587080
[2017-11-11 21:59:54 UTC] evhan changed status from new to closed
[2017-11-11 21:59:54 UTC] evhan set resolution to fixed
[2017-11-11 21:59:54 UTC] evhan wrote:
Fixed with a0bb345 and c3393980.