0.8.11.8
[sbcl.git] / BUGS
1 REPORTING BUGS
2
3 Bugs can be reported on the help mailing list
4   sbcl-help@lists.sourceforge.net
5 or on the development mailing list
6   sbcl-devel@lists.sourceforge.net
7
8 Please include enough information in a bug report that someone reading
9 it can reproduce the problem, i.e. don't write
10      Subject: apparent bug in PRINT-OBJECT (or *PRINT-LENGTH*?)
11      PRINT-OBJECT doesn't seem to work with *PRINT-LENGTH*. Is this a bug?
12 but instead
13      Subject: apparent bug in PRINT-OBJECT (or *PRINT-LENGTH*?)
14      In sbcl-1.2.3 running under OpenBSD 4.5 on my Alpha box, when
15      I compile and load the file
16        (DEFSTRUCT (FOO (:PRINT-OBJECT (LAMBDA (X Y)
17                                         (LET ((*PRINT-LENGTH* 4))
18                                           (PRINT X Y)))))
19          X Y)
20      then at the command line type
21        (MAKE-FOO)
22      the program loops endlessly instead of printing the object.
23
24
25 NOTES:
26
27 There is also some information on bugs in the manual page and
28 in the TODO file. Eventually more such information may move here.
29
30 The gaps in the number sequence belong to old bug descriptions which
31 have gone away (typically because they were fixed, but sometimes for
32 other reasons, e.g. because they were moved elsewhere).
33
34
35 2:
36   DEFSTRUCT almost certainly should overwrite the old LAYOUT information
37   instead of just punting when a contradictory structure definition
38   is loaded. As it is, if you redefine DEFSTRUCTs in a way which 
39   changes their layout, you probably have to rebuild your entire
40   program, even if you know or guess enough about the internals of
41   SBCL to wager that this (undefined in ANSI) operation would be safe.
42
43 3: "type checking of structure slots"
44   a:
45   ANSI specifies that a type mismatch in a structure slot
46   initialization value should not cause a warning.
47 WORKAROUND:
48   This one might not be fixed for a while because while we're big
49   believers in ANSI compatibility and all, (1) there's no obvious
50   simple way to do it (short of disabling all warnings for type
51   mismatches everywhere), and (2) there's a good portable
52   workaround, and (3) by their own reasoning, it looks as though
53   ANSI may have gotten it wrong. ANSI justifies this specification
54   by saying 
55     The restriction against issuing a warning for type mismatches
56     between a slot-initform and the corresponding slot's :TYPE
57     option is necessary because a slot-initform must be specified
58     in order to specify slot options; in some cases, no suitable
59     default may exist.
60   However, in SBCL (as in CMU CL or, for that matter, any compiler
61   which really understands Common Lisp types) a suitable default
62   does exist, in all cases, because the compiler understands the
63   concept of functions which never return (i.e. has return type NIL).
64   Thus, as a portable workaround, you can use a call to some
65   known-never-to-return function as the default. E.g.
66     (DEFSTRUCT FOO
67       (BAR (ERROR "missing :BAR argument")
68            :TYPE SOME-TYPE-TOO-HAIRY-TO-CONSTRUCT-AN-INSTANCE-OF))
69   or 
70     (DECLAIM (FTYPE (FUNCTION () NIL) MISSING-ARG))
71     (DEFUN REQUIRED-ARG () ; workaround for SBCL non-ANSI slot init typing
72       (ERROR "missing required argument")) 
73     (DEFSTRUCT FOO
74       (BAR (REQUIRED-ARG) :TYPE TRICKY-TYPE-OF-SOME-SORT)
75       (BLETCH (REQUIRED-ARG) :TYPE TRICKY-TYPE-OF-SOME-SORT)
76       (N-REFS-SO-FAR 0 :TYPE (INTEGER 0)))
77   Such code should compile without complaint and work correctly either
78   on SBCL or on any other completely compliant Common Lisp system.
79
80   b: &AUX argument in a boa-constructor without a default value means
81      "do not initilize this slot" and does not cause type error. But
82      an error may be signalled at read time and it would be good if
83      SBCL did it.
84
85   d: (fixed in 0.8.1.5)
86
87 7:
88   The "compiling top-level form:" output ought to be condensed.
89   Perhaps any number of such consecutive lines ought to turn into a
90   single "compiling top-level forms:" line.
91
92 19:
93   (I *think* this is a bug. It certainly seems like strange behavior. But
94   the ANSI spec is scary, dark, and deep.. -- WHN)
95     (FORMAT NIL  "~,1G" 1.4) => "1.    "
96     (FORMAT NIL "~3,1G" 1.4) => "1.    "
97
98 27:
99   Sometimes (SB-EXT:QUIT) fails with 
100         Argh! maximum interrupt nesting depth (4096) exceeded, exiting
101         Process inferior-lisp exited abnormally with code 1
102   I haven't noticed a repeatable case of this yet.
103
104 32:
105   The printer doesn't report closures very well. This is true in 
106   CMU CL 18b as well:
107     (PRINT #'CLASS-NAME)
108   gives
109     #<Closure Over Function "DEFUN STRUCTURE-SLOT-ACCESSOR" {134D1A1}>
110   It would be nice to make closures have a settable name slot,
111   and make things like DEFSTRUCT and FLET, which create closures,
112   set helpful values into this slot.
113
114 33:
115   And as long as we're wishing, it would be awfully nice if INSPECT could
116   also report on closures, telling about the values of the bound variables.
117
118 35:
119   The compiler assumes that any time a function of declared FTYPE
120   doesn't signal an error, its arguments were of the declared type.
121   E.g. compiling and loading
122     (DECLAIM (OPTIMIZE (SAFETY 3)))
123     (DEFUN FACTORIAL (X) (GAMMA (1+ X)))
124     (DEFUN GAMMA (X) X)
125     (DECLAIM (FTYPE (FUNCTION (UNSIGNED-BYTE)) FACTORIAL))
126     (DEFUN FOO (X)
127       (COND ((> (FACTORIAL X) 1.0E6)
128              (FORMAT T "too big~%"))
129             ((INTEGERP X)
130              (FORMAT T "exactly ~S~%" (FACTORIAL X)))
131             (T
132              (FORMAT T "approximately ~S~%" (FACTORIAL X)))))
133   then executing
134     (FOO 1.5)
135   will cause the INTEGERP case to be selected, giving bogus output a la
136     exactly 2.5
137   This violates the "declarations are assertions" principle.
138   According to the ANSI spec, in the section "System Class FUNCTION",
139   this is a case of "lying to the compiler", but the lying is done
140   by the code which calls FACTORIAL with non-UNSIGNED-BYTE arguments,
141   not by the unexpectedly general definition of FACTORIAL. In any case,
142   "declarations are assertions" means that lying to the compiler should
143   cause an error to be signalled, and should not cause a bogus
144   result to be returned. Thus, the compiler should not assume
145   that arbitrary functions check their argument types. (It might
146   make sense to add another flag (CHECKED?) to DEFKNOWN to 
147   identify functions which *do* check their argument types.)
148   (Also, verify that the compiler handles declared function
149   return types as assertions.)
150
151 42:
152   The definitions of SIGCONTEXT-FLOAT-REGISTER and
153   %SET-SIGCONTEXT-FLOAT-REGISTER in x86-vm.lisp say they're not
154   supported on FreeBSD because the floating point state is not saved,
155   but at least as of FreeBSD 4.0, the floating point state *is* saved,
156   so they could be supported after all. Very likely 
157   SIGCONTEXT-FLOATING-POINT-MODES could now be supported, too.
158
159 60:
160   The debugger LIST-LOCATIONS command doesn't work properly.
161   (How should it work properly?)
162
163 61:
164   Compiling and loading
165     (DEFUN FAIL (X) (THROW 'FAIL-TAG X))
166     (FAIL 12)
167   then requesting a BACKTRACE at the debugger prompt gives no information
168   about where in the user program the problem occurred.
169
170 64:
171   Using the pretty-printer from the command prompt gives funny
172   results, apparently because the pretty-printer doesn't know
173   about user's command input, including the user's carriage return
174   that the user, and therefore the pretty-printer thinks that
175   the new output block should start indented 2 or more characters
176   rightward of the correct location.
177
178 67:
179   As reported by Winton Davies on a CMU CL mailing list 2000-01-10,
180   and reported for SBCL by Martin Atzmueller 2000-10-20: (TRACE GETHASH)
181   crashes SBCL. In general tracing anything which is used in the 
182   implementation of TRACE is likely to have the same problem.
183
184 78:
185   ANSI says in one place that type declarations can be abbreviated even
186   when the type name is not a symbol, e.g.
187     (DECLAIM ((VECTOR T) *FOOVECTOR*))
188   SBCL doesn't support this. But ANSI says in another place that this
189   isn't allowed. So it's not clear this is a bug after all. (See the
190   e-mail on cmucl-help@cons.org on 2001-01-16 and 2001-01-17 from WHN
191   and Pierre Mai.)
192
193 79:
194   as pointed out by Dan Barlow on sbcl-devel 2000-07-02:
195   The PICK-TEMPORARY-FILE-NAME utility used by LOAD-FOREIGN uses
196   an easily guessable temporary filename in a way which might open
197   applications using LOAD-FOREIGN to hijacking by malicious users
198   on the same machine. Incantations for doing this safely are
199   floating around the net in various "how to write secure programs
200   despite Unix" documents, and it would be good to (1) fix this in 
201   LOAD-FOREIGN, and (2) hunt for any other code which uses temporary
202   files and make it share the same new safe logic.
203
204   (partially alleviated in sbcl-0.7.9.32 by a fix by Matthew Danish to
205    make the temporary filename less easily guessable)
206
207 83:
208   RANDOM-INTEGER-EXTRA-BITS=10 may not be large enough for the RANDOM
209   RNG to be high quality near RANDOM-FIXNUM-MAX; it looks as though
210   the mean of the distribution can be systematically O(0.1%) wrong.
211   Just increasing R-I-E-B is probably not a good solution, since
212   it would decrease efficiency more than is probably necessary. Perhaps
213   using some sort of accept/reject method would be better.
214
215 85:
216   Internally the compiler sometimes evaluates
217     (sb-kernel:type/= (specifier-type '*) (specifier-type t))
218   (I stumbled across this when I added an
219     (assert (not (eq type1 *wild-type*)))
220   in the NAMED :SIMPLE-= type method.) '* isn't really a type, and
221   in a type context should probably be translated to T, and so it's
222   probably wrong to ask whether it's equal to the T type and then (using
223   the EQ type comparison in the NAMED :SIMPLE-= type method) return NIL.
224   (I haven't tried to investigate this bug enough to guess whether
225   there might be any user-level symptoms.)
226
227   In fact, the type system is likely to depend on this inequality not
228   holding... * is not equivalent to T in many cases, such as 
229     (VECTOR *) /= (VECTOR T).
230
231 95:
232   The facility for dumping a running Lisp image to disk gets confused
233   when run without the PURIFY option, and creates an unnecessarily large
234   core file (apparently representing memory usage up to the previous
235   high-water mark). Moreover, when the file is loaded, it confuses the
236   GC, so that thereafter memory usage can never be reduced below that
237   level.
238
239   (As of 0.8.7.3 it's likely that the latter half of this bug is fixed.
240   The interaction between gencgc and the variables used by
241   save-lisp-and-die is still nonoptimal, though, so no respite from
242   big core files yet)
243
244 98:
245   In sbcl-0.6.11.41 (and in all earlier SBCL, and in CMU
246   CL), out-of-line structure slot setters are horribly inefficient
247   whenever the type of the slot is declared, because out-of-line
248   structure slot setters are implemented as closures to save space,
249   so the compiler doesn't compile the type test into code, but
250   instead just saves the type in a lexical closure and interprets it
251   at runtime.
252     To exercise the problem, compile and load
253       (cl:in-package :cl-user)
254       (defstruct foo
255         (bar (error "missing") :type bar))
256       (defvar *foo*)
257       (defun wastrel1 (x)
258         (loop (setf (foo-bar *foo*) x)))
259       (defstruct bar)
260       (defvar *bar* (make-bar))
261       (defvar *foo* (make-foo :bar *bar*))
262       (defvar *setf-foo-bar* #'(setf foo-bar))
263       (defun wastrel2 (x)
264         (loop (funcall *setf-foo-bar* x *foo*)))
265   then run (WASTREL1 *BAR*) or (WASTREL2 *BAR*), hit Ctrl-C, and
266   use BACKTRACE, to see it's spending all essentially all its time
267   in %TYPEP and VALUES-SPECIFIER-TYPE and so forth.
268     One possible solution would be simply to give up on 
269   representing structure slot accessors as functions, and represent
270   them as macroexpansions instead. This can be inconvenient for users,
271   but it's not clear that it's worse than trying to help by expanding
272   into a horribly inefficient implementation.
273     As a workaround for the problem, #'(SETF FOO) expressions
274   can be replaced with (EFFICIENT-SETF-FUNCTION FOO), where
275 (defmacro efficient-setf-function (place-function-name)
276   (or #+sbcl (and (sb-int:info :function :accessor-for place-function-name)
277                   ;; a workaround for the problem, encouraging the
278                   ;; inline expansion of the structure accessor, so
279                   ;; that the compiler can optimize its type test
280                   (let ((new-value (gensym "NEW-VALUE-"))
281                         (structure-value (gensym "STRUCTURE-VALUE-")))
282                     `(lambda (,new-value ,structure-value)
283                        (setf (,place-function-name ,structure-value)
284                              ,new-value))))
285       ;; no problem, can just use the ordinary expansion
286       `(function (setf ,place-function-name))))
287
288 100:
289   There's apparently a bug in CEILING optimization which caused 
290   Douglas Crosher to patch the CMU CL version. Martin Atzmueller
291   applied the patches to SBCL and they didn't seem to cause problems
292   (as reported sbcl-devel 2001-05-04). However, since the patches
293   modify nontrivial code which was apparently written incorrectly
294   the first time around, until regression tests are written I'm not 
295   comfortable merging the patches in the CVS version of SBCL.
296
297 108:
298   (TIME (ROOM T)) reports more than 200 Mbytes consed even for
299   a clean, just-started SBCL system. And it seems to be right:
300   (ROOM T) can bring a small computer to its knees for a *long*
301   time trying to GC afterwards. Surely there's some more economical
302   way to implement (ROOM T).
303
304   Daniel Barlow doesn't know what fixed this, but observes that it 
305   doesn't seem to be the case in 0.8.7.3 any more.  Instead, (ROOM T)
306   in a fresh SBCL causes
307
308     debugger invoked on a SB-INT:BUG in thread 5911:
309         failed AVER: "(SAP= CURRENT END)"
310
311   unless a GC has happened beforehand.
312
313 117:
314   When the compiler inline expands functions, it may be that different
315   kinds of return values are generated from different code branches.
316   E.g. an inline expansion of POSITION generates integer results 
317   from one branch, and NIL results from another. When that inline
318   expansion is used in a context where only one of those results
319   is acceptable, e.g.
320     (defun foo (x)
321       (aref *a1* (position x *a2*)))
322   and the compiler can't prove that the unacceptable branch is 
323   never taken, then bogus type mismatch warnings can be generated.
324   If you need to suppress the type mismatch warnings, you can
325   suppress the inline expansion,
326     (defun foo (x)
327       #+sbcl (declare (notinline position)) ; to suppress bug 117 bogowarnings
328       (aref *a1* (position x *a2*)))
329   or, sometimes, suppress them by declaring the result to be of an
330   appropriate type,
331     (defun foo (x)
332       (aref *a1* (the integer (position x *a2*))))
333
334   This is not a new compiler problem in 0.7.0, but the new compiler
335   transforms for FIND, POSITION, FIND-IF, and POSITION-IF make it 
336   more conspicuous. If you don't need performance from these functions,
337   and the bogus warnings are a nuisance for you, you can return to
338   your pre-0.7.0 state of grace with
339     #+sbcl (declaim (notinline find position find-if position-if)) ; bug 117..
340
341   (see also bug 279)
342
343 124:
344    As of version 0.pre7.14, SBCL's implementation of MACROLET makes
345    the entire lexical environment at the point of MACROLET available
346    in the bodies of the macroexpander functions. In particular, it
347    allows the function bodies (which run at compile time) to try to
348    access lexical variables (which are only defined at runtime).
349    It doesn't even issue a warning, which is bad.
350
351    The SBCL behavior arguably conforms to the ANSI spec (since the
352    spec says that the behavior is undefined, ergo anything conforms).
353    However, it would be better to issue a compile-time error.
354    Unfortunately I (WHN) don't see any simple way to detect this
355    condition in order to issue such an error, so for the meantime
356    SBCL just does this weird broken "conforming" thing.
357
358    The ANSI standard says, in the definition of the special operator
359    MACROLET,
360        The macro-expansion functions defined by MACROLET are defined
361        in the lexical environment in which the MACROLET form appears.
362        Declarations and MACROLET and SYMBOL-MACROLET definitions affect
363        the local macro definitions in a MACROLET, but the consequences
364        are undefined if the local macro definitions reference any
365        local variable or function bindings that are visible in that
366        lexical environment.
367    Then it seems to contradict itself by giving the example
368         (defun foo (x flag)
369            (macrolet ((fudge (z)
370                          ;The parameters x and flag are not accessible
371                          ; at this point; a reference to flag would be to
372                          ; the global variable of that name.
373                          ` (if flag (* ,z ,z) ,z)))
374             ;The parameters x and flag are accessible here.
375              (+ x
376                 (fudge x)
377                 (fudge (+ x 1)))))
378    The comment "a reference to flag would be to the global variable
379    of the same name" sounds like good behavior for the system to have.
380    but actual specification quoted above says that the actual behavior
381    is undefined.
382
383    (Since 0.7.8.23 macroexpanders are defined in a restricted version
384    of the lexical environment, containing no lexical variables and
385    functions, which seems to conform to ANSI and CLtL2, but signalling
386    a STYLE-WARNING for references to variables similar to locals might
387    be a good thing.)
388
389 125:
390    (as reported by Gabe Garza on cmucl-help 2001-09-21)
391         (defvar *tmp* 3)
392         (defun test-pred (x y)
393           (eq x y))
394         (defun test-case ()
395           (let* ((x *tmp*)
396                  (func (lambda () x)))
397             (print (eq func func))
398             (print (test-pred func func))
399             (delete func (list func))))
400    Now calling (TEST-CASE) gives output
401      NIL
402      NIL
403      (#<FUNCTION {500A9EF9}>)
404    Evidently Python thinks of the lambda as a code transformation so
405    much that it forgets that it's also an object.
406
407 135:
408   Ideally, uninterning a symbol would allow it, and its associated
409   FDEFINITION and PROCLAIM data, to be reclaimed by the GC. However,
410   at least as of sbcl-0.7.0, this isn't the case. Information about
411   FDEFINITIONs and PROCLAIMed properties is stored in globaldb.lisp
412   essentially in ordinary (non-weak) hash tables keyed by symbols.
413   Thus, once a system has an entry in this system, it tends to live
414   forever, even when it is uninterned and all other references to it
415   are lost.
416
417 143:
418   (reported by Jesse Bouwman 2001-10-24 through the unfortunately
419   prominent SourceForge web/db bug tracking system, which is 
420   unfortunately not a reliable way to get a timely response from
421   the SBCL maintainers)
422       In the course of trying to build a test case for an 
423     application error, I encountered this behavior: 
424       If you start up sbcl, and then lay on CTRL-C for a 
425     minute or two, the lisp process will eventually say: 
426          %PRIMITIVE HALT called; the party is over. 
427     and throw you into the monitor. If I start up lisp, 
428     attach to the process with strace, and then do the same 
429     (abusive) thing, I get instead: 
430          access failure in heap page not marked as write-protected 
431     and the monitor again. I don't know enough to have the 
432     faintest idea of what is going on here. 
433       This is with sbcl 6.12, uname -a reports: 
434          Linux prep 2.2.19 #4 SMP Tue Apr 24 13:59:52 CDT 2001 i686 unknown 
435   I (WHN) have verified that the same thing occurs on sbcl-0.pre7.141
436   under OpenBSD 2.9 on my X86 laptop. Do be patient when you try it:
437   it took more than two minutes (but less than five) for me.
438
439 145:
440   a.
441   ANSI allows types `(COMPLEX ,FOO) to use very hairy values for
442   FOO, e.g. (COMPLEX (AND REAL (SATISFIES ODDP))). The old CMU CL
443   COMPLEX implementation didn't deal with this, and hasn't been
444   upgraded to do so. (This doesn't seem to be a high priority
445   conformance problem, since seems hard to construct useful code
446   where it matters.)
447
448   b. (fixed in 0.8.3.43)
449
450 146:
451   Floating point errors are reported poorly. E.g. on x86 OpenBSD
452   with sbcl-0.7.1, 
453         * (expt 2.0 12777)
454         debugger invoked on condition of type SB-KERNEL:FLOATING-POINT-EXCEPTION:
455           An arithmetic error SB-KERNEL:FLOATING-POINT-EXCEPTION was signalled.
456         No traps are enabled? How can this be?
457   It should be possible to be much more specific (overflow, division
458   by zero, etc.) and of course the "How can this be?" should be fixable.
459
460   See also bugs #45.c and #183
461
462 162:
463   (reported by Robert E. Brown 2002-04-16) 
464   When a function is called with too few arguments, causing the
465   debugger to be entered, the uninitialized slots in the bad call frame 
466   seem to cause GCish problems, being interpreted as tagged data even
467   though they're not. In particular, executing ROOM in the
468   debugger at that point causes AVER failures:
469     * (machine-type)
470     "X86"
471     * (lisp-implementation-version)
472     "0.7.2.12"
473     * (typep 10)
474     ...
475     0] (room)
476     ...
477     failed AVER: "(SAP= CURRENT END)"
478   (Christophe Rhodes reports that this doesn't occur on the SPARC, which
479   isn't too surprising since there are many differences in stack
480   implementation and GC conservatism between the X86 and other ports.)
481
482   This is probably the same bug as 216
483
484 167:
485   In sbcl-0.7.3.11, compiling the (illegal) code 
486     (in-package :cl-user)
487     (defmethod prove ((uustk uustk))
488       (zap ((frob () nil))
489         (frob)))
490   gives the (not terribly clear) error message
491     ; caught ERROR:
492     ;   (during macroexpansion of (DEFMETHOD PROVE ...))
493     ; can't get template for (FROB NIL NIL)
494   The problem seems to be that the code walker used by the DEFMETHOD
495   macro is unhappy with the illegal syntax in the method body, and
496   is giving an unclear error message.
497
498 173:
499   The compiler sometimes tries to constant-fold expressions before
500   it checks to see whether they can be reached. This can lead to 
501   bogus warnings about errors in the constant folding, e.g. in code
502   like 
503     (WHEN X
504       (WRITE-STRING (> X 0) "+" "0"))
505   compiled in a context where the compiler can prove that X is NIL,
506   and the compiler complains that (> X 0) causes a type error because
507   NIL isn't a valid argument to #'>. Until sbcl-0.7.4.10 or so this
508   caused a full WARNING, which made the bug really annoying because then 
509   COMPILE and COMPILE-FILE returned FAILURE-P=T for perfectly legal
510   code. Since then the warning has been downgraded to STYLE-WARNING, 
511   so it's still a bug but at least it's a little less annoying.
512
513 183: "IEEE floating point issues"
514   Even where floating point handling is being dealt with relatively
515   well (as of sbcl-0.7.5, on sparc/sunos and alpha; see bug #146), the
516   accrued-exceptions and current-exceptions part of the fp control
517   word don't seem to bear much relation to reality. E.g. on
518   SPARC/SunOS:
519   * (/ 1.0 0.0)
520
521   debugger invoked on condition of type DIVISION-BY-ZERO:
522     arithmetic error DIVISION-BY-ZERO signalled
523   0] (sb-vm::get-floating-point-modes)
524
525   (:TRAPS (:OVERFLOW :INVALID :DIVIDE-BY-ZERO)
526           :ROUNDING-MODE :NEAREST
527           :CURRENT-EXCEPTIONS NIL
528           :ACCRUED-EXCEPTIONS (:INEXACT)
529           :FAST-MODE NIL)
530   0] abort
531   * (sb-vm::get-floating-point-modes)
532   (:TRAPS (:OVERFLOW :INVALID :DIVIDE-BY-ZERO)
533           :ROUNDING-MODE :NEAREST
534           :CURRENT-EXCEPTIONS (:INEXACT)
535           :ACCRUED-EXCEPTIONS (:INEXACT)
536           :FAST-MODE NIL)
537
538 188: "compiler performance fiasco involving type inference and UNION-TYPE"
539     (time (compile
540            nil
541            '(lambda ()
542              (declare (optimize (safety 3)))
543              (declare (optimize (compilation-speed 2)))
544              (declare (optimize (speed 1) (debug 1) (space 1)))
545              (let ((start 4))
546                (declare (type (integer 0) start))
547                (print (incf start 22))
548                (print (incf start 26))
549                (print (incf start 28)))
550              (let ((start 6))
551                (declare (type (integer 0) start))
552                (print (incf start 22))
553                (print (incf start 26)))
554              (let ((start 10))
555                (declare (type (integer 0) start))
556                (print (incf start 22))
557                (print (incf start 26))))))
558
559   This example could be solved with clever enough constraint
560   propagation or with SSA, but consider
561
562     (let ((x 0))
563       (loop (incf x 2)))
564
565   The careful type of X is {2k} :-(. Is it really important to be
566   able to work with unions of many intervals?
567
568 191: "Miscellaneous PCL deficiencies"
569   (reported by Alexey Dejneka sbcl-devel 2002-08-04)
570   a. DEFCLASS does not inform the compiler about generated
571      functions. Compiling a file with
572        (DEFCLASS A-CLASS ()
573          ((A-CLASS-X)))
574        (DEFUN A-CLASS-X (A)
575          (WITH-SLOTS (A-CLASS-X) A
576            A-CLASS-X))
577      results in a STYLE-WARNING:
578        undefined-function 
579          SB-SLOT-ACCESSOR-NAME::|COMMON-LISP-USER A-CLASS-X slot READER|
580
581      APD's fix for this was checked in to sbcl-0.7.6.20, but Pierre
582      Mai points out that the declamation of functions is in fact
583      incorrect in some cases (most notably for structure
584      classes).  This means that at present erroneous attempts to use
585      WITH-SLOTS and the like on classes with metaclass STRUCTURE-CLASS
586      won't get the corresponding STYLE-WARNING.
587   c. (fixed in 0.8.4.23)
588
589 201: "Incautious type inference from compound types"
590   a. (reported by APD sbcl-devel 2002-09-17)
591     (DEFUN FOO (X)
592       (LET ((Y (CAR (THE (CONS INTEGER *) X))))
593         (SETF (CAR X) NIL)
594         (FORMAT NIL "~S IS ~S, Y = ~S"
595                 (CAR X)
596                 (TYPECASE (CAR X)
597                   (INTEGER 'INTEGER)
598                   (T '(NOT INTEGER)))
599                 Y)))
600
601     (FOO ' (1 . 2)) => "NIL IS INTEGER, Y = 1"
602
603   b.
604     * (defun foo (x)
605         (declare (type (array * (4 4)) x))
606         (let ((y x))
607           (setq x (make-array '(4 4)))
608           (adjust-array y '(3 5))
609           (= (array-dimension y 0) (eval `(array-dimension ,y 0)))))
610     FOO
611     * (foo (make-array '(4 4) :adjustable t))
612     NIL
613
614 205: "environment issues in cross compiler"
615   (These bugs have no impact on user code, but should be fixed or
616   documented.)
617   a. Macroexpanders introduced with MACROLET are defined in the null
618      lexical environment.
619   b. The body of (EVAL-WHEN (:COMPILE-TOPLEVEL) ...) is evaluated in
620      the null lexical environment.
621   c. The cross-compiler cannot inline functions defined in a non-null
622      lexical environment.
623
624 206: ":SB-FLUID feature broken"
625   (reported by Antonio Martinez-Shotton sbcl-devel 2002-10-07)
626   Enabling :SB-FLUID in the target-features list in sbcl-0.7.8 breaks
627   the build.
628
629 207: "poorly distributed SXHASH results for compound data"
630   SBCL's SXHASH could probably try a little harder. ANSI: "the
631   intent is that an implementation should make a good-faith
632   effort to produce hash-codes that are well distributed
633   within the range of non-negative fixnums". But
634         (let ((hits (make-hash-table)))
635           (dotimes (i 16)
636             (dotimes (j 16)
637               (let* ((ij (cons i j))
638                      (newlist (push ij (gethash (sxhash ij) hits))))
639                 (when (cdr newlist)
640                   (format t "~&collision: ~S~%" newlist))))))
641   reports lots of collisions in sbcl-0.7.8. A stronger MIX function
642   would be an obvious way of fix. Maybe it would be acceptably efficient
643   to redo MIX using a lookup into a 256-entry s-box containing
644   29-bit pseudorandom numbers?
645
646 211: "keywords processing"
647   a. :ALLOW-OTHER-KEYS T should allow a function to receive an odd
648      number of keyword arguments.
649   e. Compiling
650
651       (flet ((foo (&key y) (list y)))
652         (list (foo :y 1 :y 2)))
653
654      issues confusing message
655
656        ; in: LAMBDA NIL
657        ;     (FOO :Y 1 :Y 2)
658        ;
659        ; caught STYLE-WARNING:
660        ;   The variable #:G15 is defined but never used.
661
662 212: "Sequence functions and circular arguments"
663   COERCE, MERGE and CONCATENATE go into an infinite loop when given
664   circular arguments; it would be good for the user if they could be
665   given an error instead (ANSI 17.1.1 allows this behaviour on the part
666   of the implementation, as conforming code cannot give non-proper
667   sequences to these functions.  MAP also has this problem (and
668   solution), though arguably the convenience of being able to do
669     (MAP 'LIST '+ FOO '#1=(1 . #1#))
670   might be classed as more important (though signalling an error when
671   all of the arguments are circular is probably desireable).
672
673 213: "Sequence functions and type checking"
674   b. MAP, when given a type argument that is SUBTYPEP LIST, does not
675      check that it will return a sequence of the given type.  Fixing
676      it along the same lines as the others (cf. work done around
677      sbcl-0.7.8.45) is possible, but doing so efficiently didn't look
678      entirely straightforward.
679   c. All of these functions will silently accept a type of the form
680        (CONS INTEGER *)
681      whether or not the return value is of this type.  This is
682      probably permitted by ANSI (see "Exceptional Situations" under
683      ANSI MAKE-SEQUENCE), but the DERIVE-TYPE mechanism does not
684      know about this escape clause, so code of the form
685        (INTEGERP (CAR (MAKE-SEQUENCE '(CONS INTEGER *) 2)))
686      can erroneously return T.
687
688 215: ":TEST-NOT handling by functions"
689   a. FIND and POSITION currently signal errors when given non-NIL for
690      both their :TEST and (deprecated) :TEST-NOT arguments, but by
691      ANSI 17.2 "the consequences are unspecified", which by ANSI 1.4.2
692      means that the effect is "unpredictable but harmless".  It's not
693      clear what that actually means; it may preclude conforming
694      implementations from signalling errors.
695   b. COUNT, REMOVE and the like give priority to a :TEST-NOT argument
696      when conflict occurs.  As a quality of implementation issue, it
697      might be preferable to treat :TEST and :TEST-NOT as being in some
698      sense the same &KEY, and effectively take the first test function in
699      the argument list.
700   c. Again, a quality of implementation issue: it would be good to issue a
701      STYLE-WARNING at compile-time for calls with :TEST-NOT, and a
702      WARNING for calls with both :TEST and :TEST-NOT; possibly this
703      latter should be WARNed about at execute-time too.
704
705 216: "debugger confused by frames with invalid number of arguments"
706   In sbcl-0.7.8.51, executing e.g. (VECTOR-PUSH-EXTEND T), BACKTRACE, Q
707   leaves the system confused, enough so that (QUIT) no longer works.
708   It's as though the process of working with the uninitialized slot in
709   the bad VECTOR-PUSH-EXTEND frame causes GC problems, though that may
710   not be the actual problem. (CMU CL 18c doesn't have problems with this.)
711
712   This is probably the same bug as 162
713
714 217: "Bad type operations with FUNCTION types"
715   In sbcl.0.7.7:
716
717     * (values-type-union (specifier-type '(function (base-char)))
718                          (specifier-type '(function (integer))))
719
720     #<FUN-TYPE (FUNCTION (BASE-CHAR) *)>
721
722   It causes insertion of wrong type assertions into generated
723   code. E.g.
724
725     (defun foo (x s)
726       (let ((f (etypecase x
727                  (character #'write-char)
728                  (integer #'write-byte))))
729         (funcall f x s)
730         (etypecase x
731           (character (write-char x s))
732           (integer (write-byte x s)))))
733
734    Then (FOO #\1 *STANDARD-OUTPUT*) signals type error.
735
736   (In 0.7.9.1 the result type is (FUNCTION * *), so Python does not
737   produce invalid code, but type checking is not accurate.)
738
739 233: bugs in constraint propagation
740   b.
741   (declaim (optimize (speed 2) (safety 3)))
742   (defun foo (x y)
743     (if (typep (prog1 x (setq x y)) 'double-float)
744         (+ x 1d0)
745         (+ x 2)))
746   (foo 1d0 5) => segmentation violation
747
748 235: "type system and inline expansion"
749   a.
750   (declaim (ftype (function (cons) number) acc))
751   (declaim (inline acc))
752   (defun acc (c)
753     (the number (car c)))
754
755   (defun foo (x y)
756     (values (locally (declare (optimize (safety 0)))
757               (acc x))
758             (locally (declare (optimize (safety 3)))
759               (acc y))))
760
761   (foo '(nil) '(t)) => NIL, T.
762
763 237: "Environment arguments to type functions"
764   a. Functions SUBTYPEP, TYPEP, UPGRADED-ARRAY-ELEMENT-TYPE, and 
765      UPGRADED-COMPLEX-PART-TYPE now have an optional environment
766      argument, but they ignore it completely.  This is almost 
767      certainly not correct.
768   b. Also, the compiler's optimizers for TYPEP have not been informed
769      about the new argument; consequently, they will not transform
770      calls of the form (TYPEP 1 'INTEGER NIL), even though this is
771      just as optimizeable as (TYPEP 1 'INTEGER).
772
773 238: "REPL compiler overenthusiasm for CLOS code"
774   From the REPL,
775     * (defclass foo () ())
776     * (defmethod bar ((x foo) (foo foo)) (call-next-method))
777   causes approximately 100 lines of code deletion notes.  Some
778   discussion on this issue happened under the title 'Three "interesting"
779   bugs in PCL', resulting in a fix for this oververbosity from the
780   compiler proper; however, the problem persists in the interactor
781   because the notion of original source is not preserved: for the
782   compiler, the original source of the above expression is (DEFMETHOD
783   BAR ((X FOO) (FOO FOO)) (CALL-NEXT-METHOD)), while by the time the
784   compiler gets its hands on the code needing compilation from the REPL,
785   it has been macroexpanded several times.
786
787   A symptom of the same underlying problem, reported by Tony Martinez:
788     * (handler-case
789         (with-input-from-string (*query-io* "    no")
790           (yes-or-no-p))
791       (simple-type-error () 'error))
792     ; in: LAMBDA NIL
793     ;     (SB-KERNEL:FLOAT-WAIT)
794     ; 
795     ; note: deleting unreachable code
796     ; compilation unit finished
797     ;   printed 1 note
798
799 242: "WRITE-SEQUENCE suboptimality"
800   (observed from clx performance)
801   In sbcl-0.7.13, WRITE-SEQUENCE of a sequence of type 
802   (SIMPLE-ARRAY (UNSIGNED-BYTE 8) (*)) on a stream with element-type
803   (UNSIGNED-BYTE 8) will write to the stream one byte at a time,
804   rather than writing the sequence in one go, leading to severe
805   performance degradation.
806
807 243: "STYLE-WARNING overenthusiasm for unused variables"
808   (observed from clx compilation)
809   In sbcl-0.7.14, in the presence of the macros
810     (DEFMACRO FOO (X) `(BAR ,X))
811     (DEFMACRO BAR (X) (DECLARE (IGNORABLE X)) 'NIL)
812   somewhat surprising style warnings are emitted for
813     (COMPILE NIL '(LAMBDA (Y) (FOO Y))):
814   ; in: LAMBDA (Y)
815   ;     (LAMBDA (Y) (FOO Y))
816   ; 
817   ; caught STYLE-WARNING:
818   ;   The variable Y is defined but never used.
819
820 245: bugs in disassembler
821   b. On X86 operand size prefix is not recognized.
822
823 251:
824   (defun foo (&key (a :x))
825     (declare (fixnum a))
826     a)
827
828   does not cause a warning. (BTW: old SBCL issued a warning, but for a
829   function, which was never called!)
830
831 256:
832   Compiler does not emit warnings for
833
834   a. (lambda () (svref (make-array 8 :adjustable t) 1))
835
836   b. (lambda (x)
837        (list (let ((y (the real x)))
838                (unless (floatp y) (error ""))
839                y)
840              (integer-length x)))
841
842   c. (lambda (x)
843        (declare (optimize (debug 0)))
844        (declare (type vector x))
845        (list (fill-pointer x)
846              (svref x 1)))
847
848 257:
849   Complex array type does not have corresponding type specifier.
850
851   This is a problem because the compiler emits optimization notes when
852   you use a non-simple array, and without a type specifier for hairy
853   array types, there's no good way to tell it you're doing it
854   intentionally so that it should shut up and just compile the code.
855
856   Another problem is confusing error message "asserted type ARRAY
857   conflicts with derived type (VALUES SIMPLE-VECTOR &OPTIONAL)" during
858   compiling (LAMBDA (V) (VALUES (SVREF V 0) (VECTOR-POP V))).
859
860   The last problem is that when type assertions are converted to type
861   checks, types are represented with type specifiers, so we could lose
862   complex attribute. (Now this is probably not important, because
863   currently checks for complex arrays seem to be performed by
864   callees.)
865
866 259:
867   (compile nil '(lambda () (aref (make-array 0) 0))) compiles without
868   warning.  Analogous cases with the index and length being equal and
869   greater than 0 are warned for; the problem here seems to be that the
870   type required for an array reference of this type is (INTEGER 0 (0))
871   which is canonicalized to NIL.
872
873 260:
874   a.
875   (let* ((s (gensym))
876          (t1 (specifier-type s)))
877     (eval `(defstruct ,s))
878     (type= t1 (specifier-type s)))
879   => NIL, NIL
880
881   (fixed in 0.8.1.24)
882
883   b. The same for CSUBTYPEP.
884
885 262: "yet another bug in inline expansion of local functions"
886   Compiler fails on
887
888     (defun foo (x y)
889       (declare (integer x y))
890       (+ (block nil
891             (flet ((xyz (u)
892                      (declare (integer u))
893                      (if (> (1+ (the unsigned-byte u)) 0)
894                          (+ 1 u)
895                          (return (+ 38 (cos (/ u 78)))))))
896               (declare (inline xyz))
897               (return-from foo
898                 (* (funcall (eval #'xyz) x)
899                    (if (> x 30)
900                        (funcall (if (> x 5) #'xyz #'identity)
901                                 (+ x 13))
902                        38)))))
903          (sin (* x y))))
904
905   Urgh... It's time to write IR1-copier.
906
907 266:
908   David Lichteblau provided (sbcl-devel 2003-06-01) a patch to fix
909   behaviour of streams with element-type (SIGNED-BYTE 8).  The patch
910   looks reasonable, if not obviously correct; however, it caused the
911   PPC/Linux port to segfault during warm-init while loading
912   src/pcl/std-class.fasl.  A workaround patch was made, but it would
913   be nice to understand why the first patch caused problems, and to
914   fix the cause if possible.
915
916 268: "wrong free declaration scope"
917   The following code must signal type error:
918
919     (locally (declare (optimize (safety 3)))
920       (flet ((foo (x &optional (y (car x)))
921                (declare (optimize (safety 0)))
922                (list x y)))
923         (funcall (eval #'foo) 1)))
924
925 269:
926   SCALE-FLOAT should accept any integer for its second argument.
927
928 270:
929   In the following function constraint propagator optimizes nothing:
930
931     (defun foo (x)
932       (declare (integer x))
933       (declare (optimize speed))
934       (typecase x
935         (fixnum "hala")
936         (fixnum "buba")
937         (bignum "hip")
938         (t "zuz")))
939
940 273:
941   Compilation of the following two forms causes "X is unbound" error:
942
943     (symbol-macrolet ((x pi))
944       (macrolet ((foo (y) (+ x y)))
945         (declaim (inline bar))
946         (defun bar (z)
947           (* z (foo 4)))))
948     (defun quux (z)
949       (bar z))
950
951   (See (COERCE (CDR X) 'FUNCTION) in IR1-CONVERT-INLINE-LAMBDA.)
952
953 274:
954   CLHS says that type declaration of a symbol macro should not affect
955   its expansion, but in SBCL it does. (If you like magic and want to
956   fix it, don't forget to change all uses of MACROEXPAND to
957   MACROEXPAND*.)
958
959 275:
960   The following code (taken from CLOCC) takes a lot of time to compile:
961
962     (defun foo (n)
963       (declare (type (integer 0 #.large-constant) n))
964       (expt 1/10 n))
965
966   (fixed in 0.8.2.51, but a test case would be good)
967
968 276:
969     (defmethod fee ((x fixnum))
970       (setq x (/ x 2))
971       x)
972     (fee 1) => type error
973
974   (taken from CLOCC)
975
976 278:
977   a.
978     (defun foo ()
979       (declare (optimize speed))
980       (loop for i of-type (integer 0) from 0 by 2 below 10
981             collect i))
982
983   uses generic arithmetic.
984
985   b. (fixed in 0.8.3.6)
986
987 279: type propagation error -- correctly inferred type goes astray?
988   In sbcl-0.8.3 and sbcl-0.8.1.47, the warning
989        The binding of ABS-FOO is a (VALUES (INTEGER 0 0)
990        &OPTIONAL), not a (INTEGER 1 536870911)
991   is emitted when compiling this file:
992     (declaim (ftype (function ((integer 0 #.most-positive-fixnum))
993                               (integer #.most-negative-fixnum 0))
994                     foo))
995     (defun foo (x)
996       (- x))
997     (defun bar (x)
998       (let* (;; Uncomment this for a type mismatch warning indicating 
999              ;; that the type of (FOO X) is correctly understood.
1000              #+nil (fs-foo (float-sign (foo x)))
1001                    ;; Uncomment this for a type mismatch warning 
1002                    ;; indicating that the type of (ABS (FOO X)) is
1003                    ;; correctly understood.
1004              #+nil (fs-abs-foo (float-sign (abs (foo x))))
1005              ;; something wrong with this one though
1006              (abs-foo (abs (foo x))))
1007         (declare (type (integer 1 100) abs-foo))
1008         (print abs-foo)))
1009
1010  (see also bug 117)
1011
1012 281: COMPUTE-EFFECTIVE-METHOD error signalling.
1013   (slightly obscured by a non-0 default value for
1014    SB-PCL::*MAX-EMF-PRECOMPUTE-METHODS*)
1015   It would be natural for COMPUTE-EFFECTIVE-METHOD to signal errors
1016   when it finds a method with invalid qualifiers.  However, it
1017   shouldn't signal errors when any such methods are not applicable to
1018   the particular call being evaluated, and certainly it shouldn't when
1019   simply precomputing effective methods that may never be called.
1020   (setf sb-pcl::*max-emf-precompute-methods* 0)
1021   (defgeneric foo (x)
1022     (:method-combination +)
1023     (:method ((x symbol)) 1)
1024     (:method + ((x number)) x))
1025   (foo 1) -> ERROR, but should simply return 1
1026
1027   The issue seems to be that construction of a discriminating function
1028   calls COMPUTE-EFFECTIVE-METHOD with methods that are not all applicable.
1029
1030 283: Thread safety: libc functions
1031   There are places that we call unsafe-for-threading libc functions
1032   that we should find alternatives for, or put locks around.  Known or
1033   strongly suspected problems, as of 0.8.3.10: please update this
1034   bug instead of creating new ones
1035
1036     localtime() - called for timezone calculations in code/time.lisp
1037
1038 284: Thread safety: special variables
1039   There are lots of special variables in SBCL, and I feel sure that at
1040   least some of them are indicative of potentially thread-unsafe 
1041   parts of the system.  See doc/internals/notes/threading-specials
1042
1043 286: "recursive known functions"
1044   Self-call recognition conflicts with known function
1045   recognition. Currently cross compiler and target COMPILE do not
1046   recognize recursion, and in target compiler it can be disabled. We
1047   can always disable it for known functions with RECURSIVE attribute,
1048   but there remains a possibility of a function with a
1049   (tail)-recursive simplification pass and transforms/VOPs for base
1050   cases.
1051
1052 287: PPC/Linux miscompilation or corruption in first GC
1053   When the runtime is compiled with -O3 on certain PPC/Linux machines, a
1054   segmentation fault is reported at the point of first triggered GC,
1055   during the compilation of DEFSTRUCT WRAPPER.  As a temporary workaround,
1056   the runtime is no longer compiled with -O3 on PPC/Linux, but it is likely
1057   that this merely obscures, not solves, the underlying problem; as and when
1058   underlying problems are fixed, it would be worth trying again to provoke
1059   this problem.
1060
1061 288: fundamental cross-compilation issues (from old UGLINESS file)
1062   Using host floating point numbers to represent target floating point
1063   numbers, or host characters to represent target characters, is
1064   theoretically shaky. (The characters are OK as long as the characters
1065   are in the ANSI-guaranteed character set, though, so they aren't a
1066   real problem as long as the sources don't need anything but that;
1067   the floats are a real problem.)
1068
1069 289: "type checking and source-transforms"
1070   a.
1071     (block nil (let () (funcall #'+ (eval 'nil) (eval '1) (return :good))))
1072   signals type error.
1073
1074   Our policy is to check argument types at the moment of a call. It
1075   disagrees with ANSI, which says that type assertions are put
1076   immediately onto argument expressions, but is easier to implement in
1077   IR1 and is more compatible to type inference, inline expansion,
1078   etc. IR1-transforms automatically keep this policy, but source
1079   transforms for associative functions (such as +), being applied
1080   during IR1-convertion, do not. It may be tolerable for direct calls
1081   (+ x y z), but for (FUNCALL #'+ x y z) it is non-conformant.
1082
1083   b. Another aspect of this problem is efficiency. [x y + z +]
1084   requires less registers than [x y z + +]. This transformation is
1085   currently performed with source transforms, but it would be good to
1086   also perform it in IR1 optimization phase.
1087
1088 290: Alpha floating point and denormalized traps
1089   In SBCL 0.8.3.6x on the alpha, we work around what appears to be a
1090   hardware or kernel deficiency: the status of the enable/disable
1091   denormalized-float traps bit seems to be ambiguous; by the time we
1092   get to os_restore_fp_control after a trap, denormalized traps seem
1093   to be enabled.  Since we don't want a trap every time someone uses a
1094   denormalized float, in general, we mask out that bit when we restore
1095   the control word; however, this clobbers any change the user might
1096   have made.
1097
1098 296:
1099   (reported by Adam Warner, sbcl-devel 2003-09-23)
1100
1101   The --load toplevel argument does not perform any sanitization of its
1102   argument.  As a result, files with Lisp pathname pattern characters
1103   (#\* or #\?, for instance) or quotation marks can cause the system
1104   to perform arbitrary behaviour.
1105
1106 297:
1107   LOOP with non-constant arithmetic step clauses suffers from overzealous
1108   type constraint: code of the form 
1109     (loop for d of-type double-float from 0d0 to 10d0 by x collect d)
1110   compiles to a type restriction on X of (AND DOUBLE-FLOAT (REAL
1111   (0))).  However, an integral value of X should be legal, because
1112   successive adds of integers to double-floats produces double-floats,
1113   so none of the type restrictions in the code is violated.
1114
1115 300: (reported by Peter Graves) Function PEEK-CHAR checks PEEK-TYPE
1116   argument type only after having read a character. This is caused
1117   with EXPLICIT-CHECK attribute in DEFKNOWN. The similar problem
1118   exists with =, /=, <, >, <=, >=. They were fixed, but it is probably
1119   less error prone to have EXPLICIT-CHECK be a local declaration,
1120   being put into the definition, instead of an attribute being kept in
1121   a separate file; maybe also put it into SB-EXT?
1122
1123 301: ARRAY-SIMPLE-=-TYPE-METHOD breaks on corner cases which can arise
1124      in NOTE-ASSUMED-TYPES
1125   In sbcl-0.8.7.32, compiling the file
1126         (defun foo (x y)
1127           (declare (type integer x))
1128           (declare (type (vector (or hash-table bit)) y))
1129           (bletch 2 y))
1130         (defun bar (x y)
1131           (declare (type integer x))
1132           (declare (type (simple-array base (2)) y))
1133           (bletch 1 y))
1134   gives the error
1135     failed AVER: "(NOT (AND (NOT EQUALP) CERTAINP))"
1136
1137 302: Undefined type messes up DATA-VECTOR-REF expansion.
1138   Compiling this file
1139     (defun dis (s ei x y)
1140       (declare (type (simple-array function (2)) s) (type ei ei))
1141       (funcall (aref s ei) x y))
1142   on sbcl-0.8.7.36/X86/Linux causes a BUG to be signalled:
1143     full call to SB-KERNEL:DATA-VECTOR-REF
1144
1145 303: "nonlinear LVARs" (aka MISC.293)
1146     (defun buu (x)
1147       (multiple-value-call #'list
1148         (block foo
1149           (multiple-value-prog1
1150               (eval '(values :a :b :c))
1151             (catch 'bar
1152               (if (> x 0)
1153                   (return-from foo
1154                     (eval `(if (> ,x 1)
1155                                1
1156                                (throw 'bar (values 3 4)))))))))))
1157
1158   (BUU 1) returns garbage.
1159
1160   The problem is that both EVALs sequentially write to the same LVAR.
1161
1162 305:
1163   (Reported by Dave Roberts.)
1164   Local INLINE/NOTINLINE declaration removes local FTYPE declaration:
1165
1166     (defun quux (x)
1167       (declare (ftype (function () (integer 0 10)) fee)
1168                (inline fee))
1169       (1+ (fee)))
1170
1171   uses generic arithmetic with INLINE and fixnum without.
1172
1173 306: "Imprecise unions of array types"
1174   a.(defun foo (x)
1175       (declare (optimize speed)
1176                (type (or (array cons) (array vector)) x))
1177       (elt (aref x 0) 0))
1178     (foo #((0))) => TYPE-ERROR
1179
1180   relatedly,
1181
1182   b.(subtypep 
1183      'array
1184      `(or
1185        ,@(loop for x across sb-vm:*specialized-array-element-type-properties*
1186                collect `(array ,(sb-vm:saetp-specifier x)))))
1187     => NIL, T (when it should be T, T)
1188
1189 308: "Characters without names"
1190     (reported by Bruno Haible sbcl-devel "character names are missing"
1191     2004-04-19)
1192   (graphic-char-p (code-char 255))
1193   => NIL
1194   (char-name (code-char 255))
1195   => NIL
1196
1197   SBCL is unsure of what to do about characters with codes in the
1198   range 128-255.  Currently they are treated as non-graphic, but don't
1199   have names, which is not compliant with the standard.  Various fixes
1200   are possible, such as
1201   * giving them names such as NON-ASCII-128;
1202   * reducing CHAR-CODE-LIMIT to 127 (almost certainly unpopular);
1203   * making the characters graphic (makes a certain amount of sense);
1204   * biting the bullet and implementing Unicode (probably quite hard).
1205
1206 309: "Dubious values for implementation limits"
1207     (reported by Bruno Haible sbcl-devel "Incorrect value of
1208     multiple-values-limit" 2004-04-19)
1209   (values-list (make-list 1000000)), on x86/linux, signals a stack
1210   exhaustion condition, despite MULTIPLE-VALUES-LIMIT being
1211   significantly larger than 1000000.  There are probably similar
1212   dubious values for CALL-ARGUMENTS-LIMIT (see cmucl-help/cmucl-imp
1213   around the same time regarding a call to LIST on sparc with 1000
1214   arguments) and other implementation limit constants.
1215
1216 311: "Tokeniser not thread-safe"
1217     (see also Robert Marlow sbcl-help "Multi threaded read chucking a
1218     spak" 2004-04-19)
1219   The tokenizer's use of *read-buffer* and *read-buffer-length* causes
1220   spurious errors should two threads attempt to tokenise at the same
1221   time.
1222
1223 314: "LOOP :INITIALLY clauses and scope of initializers"
1224   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1225   test suite, originally by Thomas F. Burdick.
1226     ;; <http://www.lisp.org/HyperSpec/Body/sec_6-1-7-2.html>
1227     ;; According to the HyperSpec 6.1.2.1.4, in for-as-equals-then, var is
1228     ;; initialized to the result of evaluating form1.  6.1.7.2 says that
1229     ;; initially clauses are evaluated in the loop prologue, which precedes all
1230     ;; loop code except for the initial settings provided by with, for, or as.
1231     (loop :for x = 0 :then (1+ x) 
1232           :for y = (1+ x) :then (ash y 1)
1233           :for z :across #(1 3 9 27 81 243) 
1234           :for w = (+ x y z)
1235           :initially (assert (zerop x)) :initially (assert (= 2 w))
1236           :until (>= w 100) :collect w)
1237     Expected: (2 6 15 38)
1238     Got:      ERROR
1239
1240 317: "FORMAT of floating point numbers"
1241   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1242   test suite.
1243     (format nil "~1F" 10) => "0." ; "10." expected
1244     (format nil "~0F" 10) => "0." ; "10." expected
1245     (format nil "~2F" 1234567.1) => "1000000." ; "1234567." expected
1246   it would be nice if whatever fixed this also untangled the two
1247   competing implementations of floating point printing (Steele and
1248   White, and Burger and Dybvig) present in src/code/print.lisp
1249
1250 318: "stack overflow in compiler warning with redefined class"
1251   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1252   test suite.
1253     (setq *print-pretty* nil)
1254     (defstruct foo a)
1255     (setf (find-class 'foo) nil)
1256     (defstruct foo slot-1)
1257   gives 
1258     ...#<SB-KERNEL:STRUCTURE-CLASSOID #<SB-KERNEL:STRUCTURE-CLASSOID #<SB-KERNEL:STRUCTURE-CLASSOID #<SB-KERNEL:STRUCTUREControl stack guard page temporarily disabled: proceed with caution
1259   (it's not really clear what it should give: is (SETF FIND-CLASS)
1260   meant to be enough to delete structure classes from the system?
1261   Giving a stack overflow is definitely suboptimal, though.)
1262
1263 319: "backquote with comma inside array"
1264   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1265   test suite.
1266     (read-from-string "`#1A(1 2 ,(+ 2 2) 4)") 
1267   gives
1268     #(1 2 ((SB-IMPL::|,|) + 2 2) 4)
1269   which probably isn't intentional.
1270
1271 323: "REPLACE, BIT-BASH and large strings"
1272   The transform for REPLACE on simple-base-strings uses BIT-BASH, which
1273   at present has an upper limit in size.  Consequently, in sbcl-0.8.10
1274     (defun foo ()
1275       (declare (optimize speed (safety 1)))
1276       (let ((x (make-string 140000000))
1277             (y (make-string 140000000)))
1278         (length (replace x y))))
1279     (foo)
1280   gives 
1281     debugger invoked on a TYPE-ERROR in thread 2412:
1282       The value 1120000000 is not of type (MOD 536870911).
1283   (see also "more and better sequence transforms" sbcl-devel 2004-05-10)
1284
1285 324: "STREAMs and :ELEMENT-TYPE with large bytesize"
1286   In theory, (open foo :element-type '(unsigned-byte <x>)) should work
1287   for all positive integral <x>.  At present, it only works for <x> up
1288   to about 1024 (and similarly for signed-byte), so
1289     (open "/dev/zero" :element-type '(unsigned-byte 1025))
1290   gives an error in sbcl-0.8.10.
1291
1292 325: "CLOSE :ABORT T on supeseding streams"
1293   Closing a stream opened with :IF-EXISTS :SUPERSEDE with :ABORT T leaves no
1294   file on disk, even if one existed before opening.
1295
1296   The illegality of this is not crystal clear, as the ANSI dictionary
1297   entry for CLOSE says that when :ABORT is T superseded files are not
1298   superseded (ie. the original should be restored), whereas the OPEN
1299   entry says about :IF-EXISTS :SUPERSEDE "If possible, the
1300   implementation should not destroy the old file until the new stream
1301   is closed." -- implying that even though undesirable, early deletion
1302   is legal. Restoring the original would none the less be the polite
1303   thing to do.
1304
1305 326: "*PRINT-CIRCLE* crosstalk between streams"
1306   In sbcl-0.8.10.48 it's possible for *PRINT-CIRCLE* references to be
1307   mixed between streams when output operations are intermingled closely
1308   enough (as by doing output on S2 from within (PRINT-OBJECT X S1) in the
1309   test case below), so that e.g. the references #2# appears on a stream
1310   with no preceding #2= on that stream to define it (because the #2= was
1311   sent to another stream).
1312     (cl:in-package :cl-user)
1313     (defstruct foo index)
1314     (defparameter *foo* (make-foo :index 4))
1315     (defstruct bar)
1316     (defparameter *bar* (make-bar))
1317     (defparameter *tangle* (list *foo* *bar* *foo*))
1318     (defmethod print-object ((foo foo) stream)
1319       (let ((index (foo-index foo)))
1320         (format *trace-output*
1321             "~&-$- emitting FOO ~D, ambient *BAR*=~S~%"
1322             index *bar*)
1323         (format stream "[FOO ~D]" index))
1324       foo)
1325     (let ((tsos (make-string-output-stream))
1326           (ssos (make-string-output-stream)))
1327       (let ((*print-circle* t)
1328         (*trace-output* tsos)
1329         (*standard-output* ssos))
1330         (prin1 *tangle* *standard-output*))
1331       (let ((string (get-output-stream-string ssos)))
1332         (unless (string= string "(#1=[FOO 4] #S(BAR) #1#)")
1333           ;; In sbcl-0.8.10.48 STRING was "(#1=[FOO 4] #2# #1#)".:-(
1334           (error "oops: ~S" string))))
1335   It might be straightforward to fix this by turning the
1336   *CIRCULARITY-HASH-TABLE* and *CIRCULARITY-COUNTER* variables into
1337   per-stream slots, but (1) it would probably be sort of messy faking
1338   up the special variable binding semantics using UNWIND-PROTECT and
1339   (2) it might be sort of a pain to test that no other bugs had been
1340   introduced. 
1341
1342 328: "Profiling generic functions", transplanted from #241
1343   (from tonyms on #lisp IRC 2003-02-25)
1344   In sbcl-0.7.12.55, typing
1345     (defclass foo () ((bar :accessor foo-bar)))
1346     (profile foo-bar)
1347     (unintern 'foo-bar)
1348     (defclass foo () ((bar :accessor foo-bar)))
1349   gives the error message
1350     "#:FOO-BAR already names an ordinary function or a macro."
1351
1352   Problem: when a generic function is profiled, it appears as an ordinary
1353   function to PCL. (Remembering the uninterned accessor is OK, as the
1354   redefinition must be able to remove old accessors from their generic
1355   functions.)
1356
1357 329: "Sequential class redefinition"
1358   reported by Bruno Haible:
1359    (defclass reactor () ((max-temp :initform 10000000)))
1360    (defvar *r1* (make-instance 'reactor))
1361    (defvar *r2* (make-instance 'reactor))
1362    (slot-value *r1* 'max-temp)
1363    (slot-value *r2* 'max-temp)
1364    (defclass reactor () ((uptime :initform 0)))
1365    (slot-value *r1* 'uptime)
1366    (defclass reactor () ((uptime :initform 0) (max-temp :initform 10000)))
1367    (slot-value *r1* 'max-temp) ; => 10000
1368    (slot-value *r2* 'max-temp) ; => 10000000 oops...
1369
1370   Possible solution: 
1371    The method effective when the wrapper is obsoleted can be saved
1372      in the wrapper, and then to update the instance just run through
1373      all the old wrappers in order from oldest to newest.
1374
1375 331: "lazy creation of CLOS classes for user-defined conditions"
1376     (defstruct foo)
1377     (defstruct (bar (:include foo)))
1378     (sb-mop:class-direct-subclasses (find-class 'foo))
1379   returns NIL, rather than a singleton list containing the BAR class.
1380
1381 332: "fasl stack inconsistency in structure redefinition"
1382   (reported by Tim Daly Jr sbcl-devel 2004-05-06)
1383   Even though structure redefinition is undefined by the standard, the
1384   following behaviour is suboptimal: running
1385     (defun stimulate-sbcl ()
1386       (let ((filename (format nil "/tmp/~A.lisp" (gensym))))
1387         ;;create a file which redefines a structure incompatibly
1388         (with-open-file (f filename :direction :output :if-exists :supersede)
1389           (print '(defstruct astruct foo) f)
1390           (print '(defstruct astruct foo bar) f))
1391         ;;compile and load the file, then invoke the continue restart on
1392         ;;the structure redefinition error
1393         (handler-bind ((error (lambda (c) (continue c))))
1394           (load (compile-file filename)))))
1395     (stimulate-sbcl)
1396   and choosing the CONTINUE restart yields the message
1397     debugger invoked on a SB-INT:BUG in thread 27726:
1398       fasl stack not empty when it should be
1399
1400 333: "CHECK-TYPE TYPE-ERROR-DATUM place"
1401   (reported by Tony Martinez sbcl-devel 2004-05-23)
1402   When CHECK-TYPE signals a TYPE-ERROR, the TYPE-ERROR-DATUM holds the
1403   lisp symbolic place in question rather than the place's value.  This
1404   seems wrong.
1405
1406 334: "COMPUTE-SLOTS used to add slots to classes"
1407   (reported by Bruno Haible sbcl-devel 2004-06-01)
1408   a. Adding a local slot does not work:
1409     (use-package "SB-PCL")
1410     (defclass b (a) ())
1411     (defmethod compute-slots ((class (eql (find-class 'b))))
1412       (append (call-next-method)
1413               (list (make-instance 'standard-effective-slot-definition
1414                       :name 'y
1415                       :allocation :instance))))
1416     (defclass a () ((x :allocation :class)))
1417     ;; A should now have a shared slot, X, and a local slot, Y.
1418     (mapcar #'slot-definition-location (class-slots (find-class 'b)))
1419   yields
1420     There is no applicable method for the generic function
1421       #<STANDARD-GENERIC-FUNCTION CLASS-SLOTS (3)>
1422     when called with arguments
1423       (NIL).
1424
1425   b. Adding a class slot does not work:
1426     (use-package "SB-PCL")
1427     (defclass b (a) ())
1428     (defmethod compute-slots ((class (eql (find-class 'b))))
1429       (append (call-next-method)
1430               (list (make-instance 'standard-effective-slot-definition
1431                       :name 'y
1432                       :allocation :class))))
1433     (defclass a () ((x :allocation :class)))
1434     ;; A should now have two shared slots, X and Y.
1435     (mapcar #'slot-definition-location (class-slots (find-class 'b)))
1436   yields
1437     There is no applicable method for the generic function
1438       #<STANDARD-GENERIC-FUNCTION SB-PCL::CLASS-SLOT-CELLS (1)>
1439     when called with arguments
1440       (NIL).
1441    
1442 336: "slot-definitions must retain the generic functions of accessors"
1443   reported by Tony Martinez:
1444     (defclass foo () ((bar :reader foo-bar)))
1445     (defun foo-bar (x) x)
1446     (defclass foo () ((bar :reader get-bar))) ; => error, should work
1447
1448   Note: just punting the accessor removal if the fdefinition
1449   is not a generic function is not enough:
1450
1451    (defclass foo () ((bar :reader foo-bar)))
1452    (defvar *reader* #'foo-bar)
1453    (defun foo-bar (x) x)
1454    (defclass foo () ((bar :initform 'ok :reader get-bar)))
1455    (funcall *reader* (make-instance 'foo)) ; should be an error, since
1456                                            ; the method must be removed
1457                                            ; by the class redefinition
1458
1459   Fixing this should also fix a subset of #328 -- update the
1460   description with a new test-case then.