bug-guile
[Top][All Lists]
Advanced

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

Error in vector-move-left! & vector-move-right!


From: Ian Price
Subject: Error in vector-move-left! & vector-move-right!
Date: Mon, 14 Feb 2011 04:21:33 +0000

Hi all,

I was trying to copy a vector slice into another destructively using
vector-move-(left!|right!) and came across a bug. If you try to fill
the whole of the destination vector, you will get an error. This
happens with both vector-move-left! and vector-move-right!, and it
does not matter if the source vector and the destination vector are
distinct.

$ guile
GNU Guile 1.9.15.76-eb7a1
Copyright (C) 1995-2011 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (define vec1 (make-vector 4 #f))
scheme@(guile-user)> (define vec2 (make-vector 4 #t))
scheme@(guile-user)> (vector-move-left! vec1 0 4 vec2 0)
ERROR: In procedure vector-move-left!:
ERROR: In procedure vector-move-left!: Argument 3 out of range: 4

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,q
scheme@(guile-user)> (define vec1 (make-vector 6 #f))
scheme@(guile-user)> (vector-move-right! vec1 1 5 vec2 0)
ERROR: In procedure vector-move-right!:
ERROR: In procedure vector-move-right!: Argument 3 out of range: 5

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,q
scheme@(guile-user)> (vector-move-left! vec1 0 6 vec1 0)
ERROR: In procedure vector-move-left!:
ERROR: In procedure vector-move-left!: Argument 3 out of range: 6

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,q


The culprit is an assertion common to both definitions in
libguile/vectors.c that only allows you to move the values if the
length of the vector to be moved is less than the length of the vector
you are moving it to.

Trivial patch is attached.

Looking forward to the release of 2.0,

Ian

Attachment: 0001-libguile-vectors.c-Fix-edge-case-in-s_scm_vector_mov.patch
Description: Binary data


reply via email to

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