﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	difficulty
849	bind: scrutinizer problem with passing along void result type	sjamaan	felix winkelmann	"The scrutinizer run of Salmonella found a problem with the ""random-mtzig"" egg, which turns out to be caused by a (small) bug in the bind egg:
http://parenteses.org/mario/misc/specialize-report/install/random-mtzig.html

A simple test:

{{{
(use srfi-4 bind)

(foreign-declare ""void foo(unsigned int *x, int y) { printf(\""%d %d\\n\"", x[1], y); }"")

(bind* ""void foo(unsigned int *x, ___length(x) int y);"")
}}}

When compiling this with {{{-scrutinize}}}, I get a similar warning:
{{{
Warning: in toplevel procedure `foo':
  access to variable `g27' which has an undefined value
}}}

This is due to the fact that the {{{make-inout-wrapper}}} helper procedure rewrites to a {{{let}}} form which returns its value. If that's a void type, it returns this ""undefined"" value, which triggers a scrutiny warning.  I'm unsure whether this is actually correct (why would it be a bug to just pass on a value?  Using it as an argument to another procedure would be an actual problem)

If this is indeed to be considered a scrutiny bug, please close this ticket and make a new one for Chicken.

Meanwhile, here's a patch for {{{bind}}} if it's to be considered a bind bug:

{{{
Index: bind-translator.scm
===================================================================
--- bind-translator.scm (revision 26708)
+++ bind-translator.scm (working copy)
@@ -895,7 +895,9 @@
                          (list tmp) ) 
                    ,@(filter-map (lambda (rvar io) (and (memq io '(out inout)) rvar))
                                  results io) )
-                 tmp) ) )
+                 (if (eq? rtype 'void)
+                      '(void)
+                      tmp)) ) )
        `(,rname ,@vars) ) ) )
 
 (define (length-procedure t)
}}}"	defect	closed	not urgent at all		unknown	4.7.x	fixed			
