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