[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in make-shared-array.

From: Steve Juranich
Subject: Bug in make-shared-array.
Date: Mon, 27 Feb 2006 16:12:07 -0700

I've tried posting a couple of messages about this via gmane.org, but
they still haven't posted to the list, that I can see.  Sorry if
people are seeing multiple versions of this.

There is a bug in scm_make_shared_array that causes things to break
when the input array is 1-d.  I thought I had a working patch for
this, but I don't.  Anyway, the offending line is libguile/unif.c:912:

  SCM_I_ARRAY_BASE (ra) = new_min = new_max = i + SCM_I_ARRAY_BASE (oldra);

As far as I can tell, there is a bug somewhere in the SCM_I_ARRAY_BASE
macro that causes things to break when oldra is a 1d uniform array. 
The value of the array base seems to be sane for multi-dimensional
arrays, but is something very strange for 1d arrays.

Here's the proof:

#include <stdio.h>
#include <libguile.h>

show_base_wrap(SCM ra) {
  size_t base = SCM_I_ARRAY_BASE(ra);
  printf("base = %d.\n", base);

init_buggy () {
  scm_c_define_gsubr("show-base", 1, 0, 0, show_base_wrap);

Then the scheme code that shows this off would be:
#! /bin/bash
exec guile -s "$0" "$@"

(use-modules (ice-9 format))

(setenv "LD_LIBRARY_PATH" (string-append ".:" (getenv "LD_LIBRARY_PATH")))

(load-extension "buggy" "init_buggy")

(define good #2((a b c) (d e f) (g h i)))
(define bad  #1(a b c d e f g h i))

(format #t "This one should work:~%~!")
(show-base good)

(format #t "While this one should be weird.~%~!")
(show-base bad)

Are there any workarounds for this?

GCC 3.4.4
SuSE 9.3 everything else.

Thanks a bunch.
Steve Juranich
Tucson, AZ

reply via email to

[Prev in Thread] Current Thread [Next in Thread]