Here's my attempt to reproduce these problems:

bug1.c:
/* gcc bug1.c -o bug1 -I. -g3 s7.o -ldl -lm -Wl,-export-dynamic */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "s7.h"

static s7_pointer g_4_values(s7_scheme *sc, s7_pointer args)
{
  return(s7_values(sc, s7_list(sc, 4, s7_make_integer(sc, 0),
                               s7_make_integer(sc, 1),
                               s7_make_integer(sc, 2),
                               s7_make_integer(sc, 3))));
}

int main(int argc, char **argv)
{
  s7_scheme *s7 = s7_init();
  s7_define_function(s7, "values4", g_4_values, 0, 0, false, NULL);
  s7_load(s7, "bug1.scm");
}


bug1.scm:
(display "ok 1 - ")
(display (list (values4)))
(newline) ; I get "ok 1 - (0 1 2 3)"

(define (bar)
  (display "not ok 2 - ")
  (display (list (values4)))
  (newline))
(bar) ; "not ok 2 - (0 1 2 3)"

(define (foo)
  (format #t "not ok 1 - ~A" (list (values4)))
  (newline) ; "not ok 1 - (0 1 2 3)"
  ;(define X (list (values4)))
  (format #t "not ok 2 - ~A" X)
  (newline) ; "unbound variable X"
  )
(foo)

(define (foo)
  (format #t "not ok 1 - ~A" (list (values4)))
  ;(newline)
  (format #t "not ok 2 - ~A" X)
  (newline)
  )

(foo) ; no segfaults, no incorrect output
; the error output precedes the #t output because it
; uses stderr which is not buffered.

_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist

Reply via email to