Subject: Re: bug#19246: bindings: void return function *can* trigger a segfault

From: [email-masked] (Ludovic Courtès)
Date: Mon, 01 Dec 2014 22:50:38 +0100

Hi,

Amirouche Boubekki <[email-masked]> skribis:

> void process(SCM integer, SCM other) {
>   int a = scm_to_int(integer);
>   int b = scm_to_int(other);
>   int i, c = 0;
>
>   for (i = 0; i<1000; i++) {
>     c = c + a + b;
>   }
> }
>
>
> void init () {
>   scm_c_define_gsubr("process", 2, 0, 0, process);
> }

Functions exposed to Scheme must always return ‘SCM’.

So ‘process’ above must be changed to return ‘SCM’, possibly the
SCM_UNSPECIFIED value since it’s a side-effecting function.

Thanks,
Ludo’.