Opened 12 years ago

Closed 12 years ago

#849 closed defect (fixed)

bind: scrutinizer problem with passing along void result type

Reported by: sjamaan Owned by: felix winkelmann
Priority: not urgent at all Milestone:
Component: unknown Version: 4.7.x
Keywords: Cc:
Estimated difficulty:

Description

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)

Change History (1)

comment:1 Changed 12 years ago by felix winkelmann

Resolution: fixed
Status: newclosed

I have disabled this warning in the scrutinizer. Accessing a variable with undefined value is completely ok, as long as the value is not used for anything.

Note: See TracTickets for help on using tickets.