SBCL 2.4.4 miscategorizes type with safety 3

Bug #2065609 reported by William G Lederer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Committed
Undecided
Unassigned

Bug Description

This code previously compiled an ran with 2.4.0.

sbcl --version
SBCL 2.4.4

uname -a
Linux park 5.15.0-106-generic #116-Ubuntu SMP Wed Apr 17 09:17:56 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

features:
(:QUICKLISP :ASDF3.3 :ASDF3.2 :ASDF3.1 :ASDF3 :ASDF2 :ASDF :OS-UNIX
 :NON-BASE-CHARS-EXIST-P :ASDF-UNICODE :ARENA-ALLOCATOR :X86-64 :GENCGC :64-BIT
 :ANSI-CL :COMMON-LISP :ELF :IEEE-FLOATING-POINT :LINUX :LITTLE-ENDIAN
 :PACKAGE-LOCAL-NICKNAMES :SB-CORE-COMPRESSION :SB-LDB :SB-PACKAGE-LOCKS
 :SB-THREAD :SB-UNICODE :SBCL :UNIX)

Code
----------------------
;;;; sort-compile.asd

(asdf:defsystem #:sort-compile
  :description "illustrate compile discrepancy"
  :author "wglb <email address hidden>"
  :license "Public Domain"
  :version "0.0.1"
  :serial t
  :components ((:file "package")
               (:file "sort-compile")))

;;;; package.lisp

(defpackage #:sort-compile
  (:use #:cl))

;;;; sort-compile.lisp

(in-package #:sort-compile)

(declaim (optimize (speed 0) (safety 3) (debug 3) (space 0)))

(defun sort-wc (fn)
  (let* ((pn (pathname-directory fn))
   (outpn (make-pathname :directory pn
          :name (pathname-name fn)
          :type "wc-srt")))
 (with-open-file (fi (probe-file fn) :direction :input)
   (let* ((prestuff (read fi)))
  (with-open-file (fo outpn :if-exists :supersede :if-does-not-exist :create)
    (let ((rest-stuff (rest prestuff)))
   (write (sort rest-stuff '< :key #'second) :stream fo))))))
  nil)

----------------------------------------
The code

(sort rest-stuff '< :key #'second)

Is flagged with

cd /home/data2/Build/sbcl/sort-compile/
3 compiler notes:

Unknown location:
  error:
    COMPILE-FILE-ERROR while
    compiling #<CL-SOURCE-FILE "sort-compile" "sort-compile">

sort-compile.lisp:16:20:
  warning:
    Derived type of ARRAY is
      (VALUES (AND (SIMPLE-ARRAY * (*)) (NOT SIMPLE-VECTOR)) &OPTIONAL),
    conflicting with its asserted type
      SIMPLE-VECTOR.
    See also:
      SBCL Manual, Handling of Types [:node]
  warning:
    Derived type of ARRAY is
      (VALUES (AND (SIMPLE-ARRAY * (*)) (NOT SIMPLE-VECTOR)) &OPTIONAL),
    conflicting with its asserted type
      SIMPLE-VECTOR.
    See also:
      SBCL Manual, Handling of Types [:node]

-----------------------------------------
The error goes away if safety is set to 0.

William G Lederer (wglb)
description: updated
Revision history for this message
Stas Boukarev (stassats) wrote :

Can you test the latest revision?

Revision history for this message
William G Lederer (wglb) wrote :

Version

SBCL 2.4.4.136-79f46d961

fixes the problem.

Thanks!

Stas Boukarev (stassats)
Changed in sbcl:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.