#654 sort + union destroys underlying union members

closed-invalid
clisp (525)
5
2012-12-28
2012-12-28
winfriedp
No

sorting a union destroys the underlying elements. I am using 'union' and not 'nunion'.

(defconstant *NEIGHBOURS2* (map 'simple-vector #'(lambda(cell)
(multiple-value-bind (r c b) (lin2rcbmvb cell)
(sort (copy-seq
(remove cell (union (union (svref *UNIT-LIST-VL2* r)
(svref *UNIT-LIST-VL2* c))
(svref *UNIT-LIST-VL2* b))))
#'<))) *CELLS*))
Without forcing an additional coy via copy-seq, some of *UNIT-LIST-VL2* gets modified.

Base info: Kubuntu 12.10, uname -a: Linux kunbuntu-x64 3.5.0-21-generic #32-Ubuntu SMP Tue Dec 11 18:51:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

clisp --version
GNU CLISP 2.49 (2010-07-07) (built on allspice.buildd [127.0.1.1])
Software: GNU C 4.6.2
gcc -falign-functions=4 -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -Wno-sign-compare -Wno-format-nonliteral -O -falign-functions=4 -DENABLE_UNICODE -DDYNAMIC_FFI -DDYNAMIC_MODULES -I. -Wl,-Bsymbolic-functions -Wl,-z,relro -lreadline -lncurses -ldl /usr/lib/libavcall.so /usr/lib/libcallback.so -L/usr/lib -lsigsegv libgnu_cl.a
SAFETY=0 TYPECODES WIDE_HARD GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.9
libreadline 5.2
libffcall 1.11
Features:
(READLINE REGEXP SYSCALLS I18N LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP LISP=CL INTERPRETER SOCKETS GENERIC-STREAMS LOGICAL-PATHNAMES SCREEN FFI GETTEXT UNICODE
BASE-CHAR=CHARACTER WORD-SIZE=64 PC386 UNIX)
C Modules: (clisp i18n syscalls regexp readline)
Installation directory: /usr/lib/clisp-2.49/
User language: ENGLISH
Machine: X86_64 (X86_64) kunbuntu-x64 [127.0.1.1]

I am building the structures *UNIT-LIST-VLx* and *NEIGHBOURSx* twice, in order to show the desctructive behaviour of sort.
SBCL and CCL do the right thing for me.

Discussion

  • winfriedp

    winfriedp - 2012-12-28

    just run as "clisp clisp-error.lisp"

     
    Attachments
  • Sam Steingold

    Sam Steingold - 2012-12-28
    • milestone: 100335 --> ANSI compliance issue
    • assigned_to: nobody --> sds
    • labels: --> clisp
    • status: open --> pending-invalid
     
  • Sam Steingold

    Sam Steingold - 2012-12-28

    this behavior is fully ANSI compliant.
    UNION does NOT modify its arguments, but its return value MAY share structure with them.
    An alternative to your approach is copying the arguments to UNION and using NUNION.

     
  • Sam Steingold

    Sam Steingold - 2012-12-28

    This bug report is now marked as "pending"/"invalid".
    This means that we think that the problem you report is not a problem with CLISP.
    Unless you - the reporter - act within 2 weeks, the bug will be permanently closed.
    Sorry about the inconvenience - we hope your silence means that you agree that this is not a bug in CLISP.

     
  • winfriedp

    winfriedp - 2012-12-28
    • status: pending-invalid --> open-invalid
     
  • winfriedp

    winfriedp - 2012-12-28

    I admit defeat and surrender. You can close the incident / case / bug report.

     
  • Sam Steingold

    Sam Steingold - 2012-12-28
    • status: open-invalid --> closed-invalid
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks