5928112be2ca9284c5bdacaa94c24af5c6362e92
[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 27:
93   Sometimes (SB-EXT:QUIT) fails with 
94         Argh! maximum interrupt nesting depth (4096) exceeded, exiting
95         Process inferior-lisp exited abnormally with code 1
96   I haven't noticed a repeatable case of this yet.
97
98 32:
99   The printer doesn't report closures very well. This is true in 
100   CMU CL 18b as well:
101     (defstruct foo bar)
102     (print #'foo-bar)
103   gives
104     #<FUNCTION "CLOSURE" {406974D5}>
105   It would be nice to make closures have a settable name slot,
106   and make things like DEFSTRUCT and FLET, which create closures,
107   set helpful values into this slot.
108
109 33:
110   And as long as we're wishing, it would be awfully nice if INSPECT could
111   also report on closures, telling about the values of the bound variables.
112
113 35:
114   The compiler assumes that any time a function of declared FTYPE
115   doesn't signal an error, its arguments were of the declared type.
116   E.g. compiling and loading
117     (DECLAIM (OPTIMIZE (SAFETY 3)))
118     (DEFUN FACTORIAL (X) (GAMMA (1+ X)))
119     (DEFUN GAMMA (X) X)
120     (DECLAIM (FTYPE (FUNCTION (UNSIGNED-BYTE)) FACTORIAL))
121     (DEFUN FOO (X)
122       (COND ((> (FACTORIAL X) 1.0E6)
123              (FORMAT T "too big~%"))
124             ((INTEGERP X)
125              (FORMAT T "exactly ~S~%" (FACTORIAL X)))
126             (T
127              (FORMAT T "approximately ~S~%" (FACTORIAL X)))))
128   then executing
129     (FOO 1.5)
130   will cause the INTEGERP case to be selected, giving bogus output a la
131     exactly 2.5
132   This violates the "declarations are assertions" principle.
133   According to the ANSI spec, in the section "System Class FUNCTION",
134   this is a case of "lying to the compiler", but the lying is done
135   by the code which calls FACTORIAL with non-UNSIGNED-BYTE arguments,
136   not by the unexpectedly general definition of FACTORIAL. In any case,
137   "declarations are assertions" means that lying to the compiler should
138   cause an error to be signalled, and should not cause a bogus
139   result to be returned. Thus, the compiler should not assume
140   that arbitrary functions check their argument types. (It might
141   make sense to add another flag (CHECKED?) to DEFKNOWN to 
142   identify functions which *do* check their argument types.)
143   (Also, verify that the compiler handles declared function
144   return types as assertions.)
145
146 42:
147   The definitions of SIGCONTEXT-FLOAT-REGISTER and
148   %SET-SIGCONTEXT-FLOAT-REGISTER in x86-vm.lisp say they're not
149   supported on FreeBSD because the floating point state is not saved,
150   but at least as of FreeBSD 4.0, the floating point state *is* saved,
151   so they could be supported after all. Very likely 
152   SIGCONTEXT-FLOATING-POINT-MODES could now be supported, too.
153
154 60:
155   The debugger LIST-LOCATIONS command doesn't work properly.
156   (How should it work properly?)
157
158 61:
159   Compiling and loading
160     (DEFUN FAIL (X) (THROW 'FAIL-TAG X))
161     (FAIL 12)
162   then requesting a BACKTRACE at the debugger prompt gives no information
163   about where in the user program the problem occurred.
164
165   (this is apparently mostly fixed on the SPARC, PPC, and x86 architectures:
166   while giving the backtrace the non-x86 systems complains about "unknown
167   source location: using block start", but apart from that the
168   backtrace seems reasonable. On x86 this is masked by bug 353. See
169   tests/debug.impure.lisp for a test case)
170
171 64:
172   Using the pretty-printer from the command prompt gives funny
173   results, apparently because the pretty-printer doesn't know
174   about user's command input, including the user's carriage return
175   that the user, and therefore the pretty-printer thinks that
176   the new output block should start indented 2 or more characters
177   rightward of the correct location.
178
179 67:
180   As reported by Winton Davies on a CMU CL mailing list 2000-01-10,
181   and reported for SBCL by Martin Atzmueller 2000-10-20: (TRACE GETHASH)
182   crashes SBCL. In general tracing anything which is used in the 
183   implementation of TRACE is likely to have the same problem.
184
185 78:
186   ANSI says in one place that type declarations can be abbreviated even
187   when the type name is not a symbol, e.g.
188     (DECLAIM ((VECTOR T) *FOOVECTOR*))
189   SBCL doesn't support this. But ANSI says in another place that this
190   isn't allowed. So it's not clear this is a bug after all. (See the
191   e-mail on cmucl-help@cons.org on 2001-01-16 and 2001-01-17 from WHN
192   and Pierre Mai.)
193
194 83:
195   RANDOM-INTEGER-EXTRA-BITS=10 may not be large enough for the RANDOM
196   RNG to be high quality near RANDOM-FIXNUM-MAX; it looks as though
197   the mean of the distribution can be systematically O(0.1%) wrong.
198   Just increasing R-I-E-B is probably not a good solution, since
199   it would decrease efficiency more than is probably necessary. Perhaps
200   using some sort of accept/reject method would be better.
201
202 85:
203   Internally the compiler sometimes evaluates
204     (sb-kernel:type/= (specifier-type '*) (specifier-type t))
205   (I stumbled across this when I added an
206     (assert (not (eq type1 *wild-type*)))
207   in the NAMED :SIMPLE-= type method.) '* isn't really a type, and
208   in a type context should probably be translated to T, and so it's
209   probably wrong to ask whether it's equal to the T type and then (using
210   the EQ type comparison in the NAMED :SIMPLE-= type method) return NIL.
211   (I haven't tried to investigate this bug enough to guess whether
212   there might be any user-level symptoms.)
213
214   In fact, the type system is likely to depend on this inequality not
215   holding... * is not equivalent to T in many cases, such as 
216     (VECTOR *) /= (VECTOR T).
217
218 95:
219   The facility for dumping a running Lisp image to disk gets confused
220   when run without the PURIFY option, and creates an unnecessarily large
221   core file (apparently representing memory usage up to the previous
222   high-water mark). Moreover, when the file is loaded, it confuses the
223   GC, so that thereafter memory usage can never be reduced below that
224   level.
225
226   (As of 0.8.7.3 it's likely that the latter half of this bug is fixed.
227   The interaction between gencgc and the variables used by
228   save-lisp-and-die is still nonoptimal, though, so no respite from
229   big core files yet)
230
231 98:
232   In sbcl-0.6.11.41 (and in all earlier SBCL, and in CMU
233   CL), out-of-line structure slot setters are horribly inefficient
234   whenever the type of the slot is declared, because out-of-line
235   structure slot setters are implemented as closures to save space,
236   so the compiler doesn't compile the type test into code, but
237   instead just saves the type in a lexical closure and interprets it
238   at runtime.
239     To exercise the problem, compile and load
240       (cl:in-package :cl-user)
241       (defstruct foo
242         (bar (error "missing") :type bar))
243       (defvar *foo*)
244       (defun wastrel1 (x)
245         (loop (setf (foo-bar *foo*) x)))
246       (defstruct bar)
247       (defvar *bar* (make-bar))
248       (defvar *foo* (make-foo :bar *bar*))
249       (defvar *setf-foo-bar* #'(setf foo-bar))
250       (defun wastrel2 (x)
251         (loop (funcall *setf-foo-bar* x *foo*)))
252   then run (WASTREL1 *BAR*) or (WASTREL2 *BAR*), hit Ctrl-C, and
253   use BACKTRACE, to see it's spending all essentially all its time
254   in %TYPEP and VALUES-SPECIFIER-TYPE and so forth.
255     One possible solution would be simply to give up on 
256   representing structure slot accessors as functions, and represent
257   them as macroexpansions instead. This can be inconvenient for users,
258   but it's not clear that it's worse than trying to help by expanding
259   into a horribly inefficient implementation.
260     As a workaround for the problem, #'(SETF FOO) expressions
261   can be replaced with (EFFICIENT-SETF-FUNCTION FOO), where
262 (defmacro efficient-setf-function (place-function-name)
263   (or #+sbcl (and (sb-int:info :function :accessor-for place-function-name)
264                   ;; a workaround for the problem, encouraging the
265                   ;; inline expansion of the structure accessor, so
266                   ;; that the compiler can optimize its type test
267                   (let ((new-value (gensym "NEW-VALUE-"))
268                         (structure-value (gensym "STRUCTURE-VALUE-")))
269                     `(lambda (,new-value ,structure-value)
270                        (setf (,place-function-name ,structure-value)
271                              ,new-value))))
272       ;; no problem, can just use the ordinary expansion
273       `(function (setf ,place-function-name))))
274
275 100:
276   There's apparently a bug in CEILING optimization which caused 
277   Douglas Crosher to patch the CMU CL version. Martin Atzmueller
278   applied the patches to SBCL and they didn't seem to cause problems
279   (as reported sbcl-devel 2001-05-04). However, since the patches
280   modify nontrivial code which was apparently written incorrectly
281   the first time around, until regression tests are written I'm not 
282   comfortable merging the patches in the CVS version of SBCL.
283
284 108:
285   (TIME (ROOM T)) reports more than 200 Mbytes consed even for
286   a clean, just-started SBCL system. And it seems to be right:
287   (ROOM T) can bring a small computer to its knees for a *long*
288   time trying to GC afterwards. Surely there's some more economical
289   way to implement (ROOM T).
290
291   Daniel Barlow doesn't know what fixed this, but observes that it 
292   doesn't seem to be the case in 0.8.7.3 any more.  Instead, (ROOM T)
293   in a fresh SBCL causes
294
295     debugger invoked on a SB-INT:BUG in thread 5911:
296         failed AVER: "(SAP= CURRENT END)"
297
298   unless a GC has happened beforehand.
299
300 117:
301   When the compiler inline expands functions, it may be that different
302   kinds of return values are generated from different code branches.
303   E.g. an inline expansion of POSITION generates integer results 
304   from one branch, and NIL results from another. When that inline
305   expansion is used in a context where only one of those results
306   is acceptable, e.g.
307     (defun foo (x)
308       (aref *a1* (position x *a2*)))
309   and the compiler can't prove that the unacceptable branch is 
310   never taken, then bogus type mismatch warnings can be generated.
311   If you need to suppress the type mismatch warnings, you can
312   suppress the inline expansion,
313     (defun foo (x)
314       #+sbcl (declare (notinline position)) ; to suppress bug 117 bogowarnings
315       (aref *a1* (position x *a2*)))
316   or, sometimes, suppress them by declaring the result to be of an
317   appropriate type,
318     (defun foo (x)
319       (aref *a1* (the integer (position x *a2*))))
320
321   This is not a new compiler problem in 0.7.0, but the new compiler
322   transforms for FIND, POSITION, FIND-IF, and POSITION-IF make it 
323   more conspicuous. If you don't need performance from these functions,
324   and the bogus warnings are a nuisance for you, you can return to
325   your pre-0.7.0 state of grace with
326     #+sbcl (declaim (notinline find position find-if position-if)) ; bug 117..
327
328   (see also bug 279)
329
330 124:
331    As of version 0.pre7.14, SBCL's implementation of MACROLET makes
332    the entire lexical environment at the point of MACROLET available
333    in the bodies of the macroexpander functions. In particular, it
334    allows the function bodies (which run at compile time) to try to
335    access lexical variables (which are only defined at runtime).
336    It doesn't even issue a warning, which is bad.
337
338    The SBCL behavior arguably conforms to the ANSI spec (since the
339    spec says that the behavior is undefined, ergo anything conforms).
340    However, it would be better to issue a compile-time error.
341    Unfortunately I (WHN) don't see any simple way to detect this
342    condition in order to issue such an error, so for the meantime
343    SBCL just does this weird broken "conforming" thing.
344
345    The ANSI standard says, in the definition of the special operator
346    MACROLET,
347        The macro-expansion functions defined by MACROLET are defined
348        in the lexical environment in which the MACROLET form appears.
349        Declarations and MACROLET and SYMBOL-MACROLET definitions affect
350        the local macro definitions in a MACROLET, but the consequences
351        are undefined if the local macro definitions reference any
352        local variable or function bindings that are visible in that
353        lexical environment.
354    Then it seems to contradict itself by giving the example
355         (defun foo (x flag)
356            (macrolet ((fudge (z)
357                          ;The parameters x and flag are not accessible
358                          ; at this point; a reference to flag would be to
359                          ; the global variable of that name.
360                          ` (if flag (* ,z ,z) ,z)))
361             ;The parameters x and flag are accessible here.
362              (+ x
363                 (fudge x)
364                 (fudge (+ x 1)))))
365    The comment "a reference to flag would be to the global variable
366    of the same name" sounds like good behavior for the system to have.
367    but actual specification quoted above says that the actual behavior
368    is undefined.
369
370    (Since 0.7.8.23 macroexpanders are defined in a restricted version
371    of the lexical environment, containing no lexical variables and
372    functions, which seems to conform to ANSI and CLtL2, but signalling
373    a STYLE-WARNING for references to variables similar to locals might
374    be a good thing.)
375
376 135:
377   Ideally, uninterning a symbol would allow it, and its associated
378   FDEFINITION and PROCLAIM data, to be reclaimed by the GC. However,
379   at least as of sbcl-0.7.0, this isn't the case. Information about
380   FDEFINITIONs and PROCLAIMed properties is stored in globaldb.lisp
381   essentially in ordinary (non-weak) hash tables keyed by symbols.
382   Thus, once a system has an entry in this system, it tends to live
383   forever, even when it is uninterned and all other references to it
384   are lost.
385
386 143:
387   (reported by Jesse Bouwman 2001-10-24 through the unfortunately
388   prominent SourceForge web/db bug tracking system, which is 
389   unfortunately not a reliable way to get a timely response from
390   the SBCL maintainers)
391       In the course of trying to build a test case for an 
392     application error, I encountered this behavior: 
393       If you start up sbcl, and then lay on CTRL-C for a 
394     minute or two, the lisp process will eventually say: 
395          %PRIMITIVE HALT called; the party is over. 
396     and throw you into the monitor. If I start up lisp, 
397     attach to the process with strace, and then do the same 
398     (abusive) thing, I get instead: 
399          access failure in heap page not marked as write-protected 
400     and the monitor again. I don't know enough to have the 
401     faintest idea of what is going on here. 
402       This is with sbcl 6.12, uname -a reports: 
403          Linux prep 2.2.19 #4 SMP Tue Apr 24 13:59:52 CDT 2001 i686 unknown 
404   I (WHN) have verified that the same thing occurs on sbcl-0.pre7.141
405   under OpenBSD 2.9 on my X86 laptop. Do be patient when you try it:
406   it took more than two minutes (but less than five) for me.
407
408 145:
409   a.
410   ANSI allows types `(COMPLEX ,FOO) to use very hairy values for
411   FOO, e.g. (COMPLEX (AND REAL (SATISFIES ODDP))). The old CMU CL
412   COMPLEX implementation didn't deal with this, and hasn't been
413   upgraded to do so. (This doesn't seem to be a high priority
414   conformance problem, since seems hard to construct useful code
415   where it matters.)
416
417   [ partially fixed by CSR in 0.8.17.17 because of a PFD ansi-tests
418     report that (COMPLEX RATIO) was failing; still failing on types of
419     the form (AND NUMBER (SATISFIES REALP) (SATISFIES ZEROP)). ]
420
421   b. (fixed in 0.8.3.43)
422
423 146:
424   Floating point errors are reported poorly. E.g. on x86 OpenBSD
425   with sbcl-0.7.1, 
426         * (expt 2.0 12777)
427         debugger invoked on condition of type SB-KERNEL:FLOATING-POINT-EXCEPTION:
428           An arithmetic error SB-KERNEL:FLOATING-POINT-EXCEPTION was signalled.
429         No traps are enabled? How can this be?
430   It should be possible to be much more specific (overflow, division
431   by zero, etc.) and of course the "How can this be?" should be fixable.
432
433   See also bugs #45.c and #183
434
435 162:
436   (reported by Robert E. Brown 2002-04-16) 
437   When a function is called with too few arguments, causing the
438   debugger to be entered, the uninitialized slots in the bad call frame 
439   seem to cause GCish problems, being interpreted as tagged data even
440   though they're not. In particular, executing ROOM in the
441   debugger at that point causes AVER failures:
442     * (machine-type)
443     "X86"
444     * (lisp-implementation-version)
445     "0.7.2.12"
446     * (typep 10)
447     ...
448     0] (room)
449     ...
450     failed AVER: "(SAP= CURRENT END)"
451   (Christophe Rhodes reports that this doesn't occur on the SPARC, which
452   isn't too surprising since there are many differences in stack
453   implementation and GC conservatism between the X86 and other ports.)
454
455   This is probably the same bug as 216
456
457 173:
458   The compiler sometimes tries to constant-fold expressions before
459   it checks to see whether they can be reached. This can lead to 
460   bogus warnings about errors in the constant folding, e.g. in code
461   like 
462     (WHEN X
463       (WRITE-STRING (> X 0) "+" "0"))
464   compiled in a context where the compiler can prove that X is NIL,
465   and the compiler complains that (> X 0) causes a type error because
466   NIL isn't a valid argument to #'>. Until sbcl-0.7.4.10 or so this
467   caused a full WARNING, which made the bug really annoying because then 
468   COMPILE and COMPILE-FILE returned FAILURE-P=T for perfectly legal
469   code. Since then the warning has been downgraded to STYLE-WARNING, 
470   so it's still a bug but at least it's a little less annoying.
471
472 183: "IEEE floating point issues"
473   Even where floating point handling is being dealt with relatively
474   well (as of sbcl-0.7.5, on sparc/sunos and alpha; see bug #146), the
475   accrued-exceptions and current-exceptions part of the fp control
476   word don't seem to bear much relation to reality. E.g. on
477   SPARC/SunOS:
478   * (/ 1.0 0.0)
479
480   debugger invoked on condition of type DIVISION-BY-ZERO:
481     arithmetic error DIVISION-BY-ZERO signalled
482   0] (sb-vm::get-floating-point-modes)
483
484   (:TRAPS (:OVERFLOW :INVALID :DIVIDE-BY-ZERO)
485           :ROUNDING-MODE :NEAREST
486           :CURRENT-EXCEPTIONS NIL
487           :ACCRUED-EXCEPTIONS (:INEXACT)
488           :FAST-MODE NIL)
489   0] abort
490   * (sb-vm::get-floating-point-modes)
491   (:TRAPS (:OVERFLOW :INVALID :DIVIDE-BY-ZERO)
492           :ROUNDING-MODE :NEAREST
493           :CURRENT-EXCEPTIONS (:INEXACT)
494           :ACCRUED-EXCEPTIONS (:INEXACT)
495           :FAST-MODE NIL)
496
497 188: "compiler performance fiasco involving type inference and UNION-TYPE"
498     (time (compile
499            nil
500            '(lambda ()
501              (declare (optimize (safety 3)))
502              (declare (optimize (compilation-speed 2)))
503              (declare (optimize (speed 1) (debug 1) (space 1)))
504              (let ((start 4))
505                (declare (type (integer 0) start))
506                (print (incf start 22))
507                (print (incf start 26))
508                (print (incf start 28)))
509              (let ((start 6))
510                (declare (type (integer 0) start))
511                (print (incf start 22))
512                (print (incf start 26)))
513              (let ((start 10))
514                (declare (type (integer 0) start))
515                (print (incf start 22))
516                (print (incf start 26))))))
517
518   This example could be solved with clever enough constraint
519   propagation or with SSA, but consider
520
521     (let ((x 0))
522       (loop (incf x 2)))
523
524   The careful type of X is {2k} :-(. Is it really important to be
525   able to work with unions of many intervals?
526
527 191: "Miscellaneous PCL deficiencies"
528   (reported by Alexey Dejneka sbcl-devel 2002-08-04)
529   a. DEFCLASS does not inform the compiler about generated
530      functions. Compiling a file with
531        (DEFCLASS A-CLASS ()
532          ((A-CLASS-X)))
533        (DEFUN A-CLASS-X (A)
534          (WITH-SLOTS (A-CLASS-X) A
535            A-CLASS-X))
536      results in a STYLE-WARNING:
537        undefined-function 
538          SB-SLOT-ACCESSOR-NAME::|COMMON-LISP-USER A-CLASS-X slot READER|
539
540      APD's fix for this was checked in to sbcl-0.7.6.20, but Pierre
541      Mai points out that the declamation of functions is in fact
542      incorrect in some cases (most notably for structure
543      classes).  This means that at present erroneous attempts to use
544      WITH-SLOTS and the like on classes with metaclass STRUCTURE-CLASS
545      won't get the corresponding STYLE-WARNING.
546   c. (fixed in 0.8.4.23)
547
548 201: "Incautious type inference from compound types"
549   a. (reported by APD sbcl-devel 2002-09-17)
550     (DEFUN FOO (X)
551       (LET ((Y (CAR (THE (CONS INTEGER *) X))))
552         (SETF (CAR X) NIL)
553         (FORMAT NIL "~S IS ~S, Y = ~S"
554                 (CAR X)
555                 (TYPECASE (CAR X)
556                   (INTEGER 'INTEGER)
557                   (T '(NOT INTEGER)))
558                 Y)))
559
560     (FOO ' (1 . 2)) => "NIL IS INTEGER, Y = 1"
561
562   b.
563     * (defun foo (x)
564         (declare (type (array * (4 4)) x))
565         (let ((y x))
566           (setq x (make-array '(4 4)))
567           (adjust-array y '(3 5))
568           (= (array-dimension y 0) (eval `(array-dimension ,y 0)))))
569     FOO
570     * (foo (make-array '(4 4) :adjustable t))
571     NIL
572
573 205: "environment issues in cross compiler"
574   (These bugs have no impact on user code, but should be fixed or
575   documented.)
576   a. Macroexpanders introduced with MACROLET are defined in the null
577      lexical environment.
578   b. The body of (EVAL-WHEN (:COMPILE-TOPLEVEL) ...) is evaluated in
579      the null lexical environment.
580   c. The cross-compiler cannot inline functions defined in a non-null
581      lexical environment.
582
583 206: ":SB-FLUID feature broken"
584   (reported by Antonio Martinez-Shotton sbcl-devel 2002-10-07)
585   Enabling :SB-FLUID in the target-features list in sbcl-0.7.8 breaks
586   the build.
587
588 207: "poorly distributed SXHASH results for compound data"
589   SBCL's SXHASH could probably try a little harder. ANSI: "the
590   intent is that an implementation should make a good-faith
591   effort to produce hash-codes that are well distributed
592   within the range of non-negative fixnums". But
593         (let ((hits (make-hash-table)))
594           (dotimes (i 16)
595             (dotimes (j 16)
596               (let* ((ij (cons i j))
597                      (newlist (push ij (gethash (sxhash ij) hits))))
598                 (when (cdr newlist)
599                   (format t "~&collision: ~S~%" newlist))))))
600   reports lots of collisions in sbcl-0.7.8. A stronger MIX function
601   would be an obvious way of fix. Maybe it would be acceptably efficient
602   to redo MIX using a lookup into a 256-entry s-box containing
603   29-bit pseudorandom numbers?
604
605 211: "keywords processing"
606   a. :ALLOW-OTHER-KEYS T should allow a function to receive an odd
607      number of keyword arguments.
608   e. Compiling
609
610       (flet ((foo (&key y) (list y)))
611         (list (foo :y 1 :y 2)))
612
613      issues confusing message
614
615        ; in: LAMBDA NIL
616        ;     (FOO :Y 1 :Y 2)
617        ;
618        ; caught STYLE-WARNING:
619        ;   The variable #:G15 is defined but never used.
620
621 212: "Sequence functions and circular arguments"
622   COERCE, MERGE and CONCATENATE go into an infinite loop when given
623   circular arguments; it would be good for the user if they could be
624   given an error instead (ANSI 17.1.1 allows this behaviour on the part
625   of the implementation, as conforming code cannot give non-proper
626   sequences to these functions.  MAP also has this problem (and
627   solution), though arguably the convenience of being able to do
628     (MAP 'LIST '+ FOO '#1=(1 . #1#))
629   might be classed as more important (though signalling an error when
630   all of the arguments are circular is probably desireable).
631
632 213: "Sequence functions and type checking"
633   b. MAP, when given a type argument that is SUBTYPEP LIST, does not
634      check that it will return a sequence of the given type.  Fixing
635      it along the same lines as the others (cf. work done around
636      sbcl-0.7.8.45) is possible, but doing so efficiently didn't look
637      entirely straightforward.
638   c. All of these functions will silently accept a type of the form
639        (CONS INTEGER *)
640      whether or not the return value is of this type.  This is
641      probably permitted by ANSI (see "Exceptional Situations" under
642      ANSI MAKE-SEQUENCE), but the DERIVE-TYPE mechanism does not
643      know about this escape clause, so code of the form
644        (INTEGERP (CAR (MAKE-SEQUENCE '(CONS INTEGER *) 2)))
645      can erroneously return T.
646
647 215: ":TEST-NOT handling by functions"
648   a. FIND and POSITION currently signal errors when given non-NIL for
649      both their :TEST and (deprecated) :TEST-NOT arguments, but by
650      ANSI 17.2 "the consequences are unspecified", which by ANSI 1.4.2
651      means that the effect is "unpredictable but harmless".  It's not
652      clear what that actually means; it may preclude conforming
653      implementations from signalling errors.
654   b. COUNT, REMOVE and the like give priority to a :TEST-NOT argument
655      when conflict occurs.  As a quality of implementation issue, it
656      might be preferable to treat :TEST and :TEST-NOT as being in some
657      sense the same &KEY, and effectively take the first test function in
658      the argument list.
659   c. Again, a quality of implementation issue: it would be good to issue a
660      STYLE-WARNING at compile-time for calls with :TEST-NOT, and a
661      WARNING for calls with both :TEST and :TEST-NOT; possibly this
662      latter should be WARNed about at execute-time too.
663
664 216: "debugger confused by frames with invalid number of arguments"
665   In sbcl-0.7.8.51, executing e.g. (VECTOR-PUSH-EXTEND T), BACKTRACE, Q
666   leaves the system confused, enough so that (QUIT) no longer works.
667   It's as though the process of working with the uninitialized slot in
668   the bad VECTOR-PUSH-EXTEND frame causes GC problems, though that may
669   not be the actual problem. (CMU CL 18c doesn't have problems with this.)
670
671   This is probably the same bug as 162
672
673 217: "Bad type operations with FUNCTION types"
674   In sbcl.0.7.7:
675
676     * (values-type-union (specifier-type '(function (base-char)))
677                          (specifier-type '(function (integer))))
678
679     #<FUN-TYPE (FUNCTION (BASE-CHAR) *)>
680
681   It causes insertion of wrong type assertions into generated
682   code. E.g.
683
684     (defun foo (x s)
685       (let ((f (etypecase x
686                  (character #'write-char)
687                  (integer #'write-byte))))
688         (funcall f x s)
689         (etypecase x
690           (character (write-char x s))
691           (integer (write-byte x s)))))
692
693    Then (FOO #\1 *STANDARD-OUTPUT*) signals type error.
694
695   (In 0.7.9.1 the result type is (FUNCTION * *), so Python does not
696   produce invalid code, but type checking is not accurate.)
697
698 233: bugs in constraint propagation
699   b.
700   (declaim (optimize (speed 2) (safety 3)))
701   (defun foo (x y)
702     (if (typep (prog1 x (setq x y)) 'double-float)
703         (+ x 1d0)
704         (+ x 2)))
705   (foo 1d0 5) => segmentation violation
706
707 235: "type system and inline expansion"
708   a.
709   (declaim (ftype (function (cons) number) acc))
710   (declaim (inline acc))
711   (defun acc (c)
712     (the number (car c)))
713
714   (defun foo (x y)
715     (values (locally (declare (optimize (safety 0)))
716               (acc x))
717             (locally (declare (optimize (safety 3)))
718               (acc y))))
719
720   (foo '(nil) '(t)) => NIL, T.
721
722 237: "Environment arguments to type functions"
723   a. Functions SUBTYPEP, TYPEP, UPGRADED-ARRAY-ELEMENT-TYPE, and 
724      UPGRADED-COMPLEX-PART-TYPE now have an optional environment
725      argument, but they ignore it completely.  This is almost 
726      certainly not correct.
727   b. Also, the compiler's optimizers for TYPEP have not been informed
728      about the new argument; consequently, they will not transform
729      calls of the form (TYPEP 1 'INTEGER NIL), even though this is
730      just as optimizeable as (TYPEP 1 'INTEGER).
731
732 238: "REPL compiler overenthusiasm for CLOS code"
733   From the REPL,
734     * (defclass foo () ())
735     * (defmethod bar ((x foo) (foo foo)) (call-next-method))
736   causes approximately 100 lines of code deletion notes.  Some
737   discussion on this issue happened under the title 'Three "interesting"
738   bugs in PCL', resulting in a fix for this oververbosity from the
739   compiler proper; however, the problem persists in the interactor
740   because the notion of original source is not preserved: for the
741   compiler, the original source of the above expression is (DEFMETHOD
742   BAR ((X FOO) (FOO FOO)) (CALL-NEXT-METHOD)), while by the time the
743   compiler gets its hands on the code needing compilation from the REPL,
744   it has been macroexpanded several times.
745
746   A symptom of the same underlying problem, reported by Tony Martinez:
747     * (handler-case
748         (with-input-from-string (*query-io* "    no")
749           (yes-or-no-p))
750       (simple-type-error () 'error))
751     ; in: LAMBDA NIL
752     ;     (SB-KERNEL:FLOAT-WAIT)
753     ; 
754     ; note: deleting unreachable code
755     ; compilation unit finished
756     ;   printed 1 note
757
758 242: "WRITE-SEQUENCE suboptimality"
759   (observed from clx performance)
760   In sbcl-0.7.13, WRITE-SEQUENCE of a sequence of type 
761   (SIMPLE-ARRAY (UNSIGNED-BYTE 8) (*)) on a stream with element-type
762   (UNSIGNED-BYTE 8) will write to the stream one byte at a time,
763   rather than writing the sequence in one go, leading to severe
764   performance degradation.
765
766 243: "STYLE-WARNING overenthusiasm for unused variables"
767   (observed from clx compilation)
768   In sbcl-0.7.14, in the presence of the macros
769     (DEFMACRO FOO (X) `(BAR ,X))
770     (DEFMACRO BAR (X) (DECLARE (IGNORABLE X)) 'NIL)
771   somewhat surprising style warnings are emitted for
772     (COMPILE NIL '(LAMBDA (Y) (FOO Y))):
773   ; in: LAMBDA (Y)
774   ;     (LAMBDA (Y) (FOO Y))
775   ; 
776   ; caught STYLE-WARNING:
777   ;   The variable Y is defined but never used.
778
779 245: bugs in disassembler
780   b. On X86 operand size prefix is not recognized.
781
782 251:
783   (defun foo (&key (a :x))
784     (declare (fixnum a))
785     a)
786
787   does not cause a warning. (BTW: old SBCL issued a warning, but for a
788   function, which was never called!)
789
790 256:
791   Compiler does not emit warnings for
792
793   a. (lambda () (svref (make-array 8 :adjustable t) 1))
794
795   b. (lambda (x)
796        (list (let ((y (the real x)))
797                (unless (floatp y) (error ""))
798                y)
799              (integer-length x)))
800
801   c. (lambda (x)
802        (declare (optimize (debug 0)))
803        (declare (type vector x))
804        (list (fill-pointer x)
805              (svref x 1)))
806
807 257:
808   Complex array type does not have corresponding type specifier.
809
810   This is a problem because the compiler emits optimization notes when
811   you use a non-simple array, and without a type specifier for hairy
812   array types, there's no good way to tell it you're doing it
813   intentionally so that it should shut up and just compile the code.
814
815   Another problem is confusing error message "asserted type ARRAY
816   conflicts with derived type (VALUES SIMPLE-VECTOR &OPTIONAL)" during
817   compiling (LAMBDA (V) (VALUES (SVREF V 0) (VECTOR-POP V))).
818
819   The last problem is that when type assertions are converted to type
820   checks, types are represented with type specifiers, so we could lose
821   complex attribute. (Now this is probably not important, because
822   currently checks for complex arrays seem to be performed by
823   callees.)
824
825 259:
826   (compile nil '(lambda () (aref (make-array 0) 0))) compiles without
827   warning.  Analogous cases with the index and length being equal and
828   greater than 0 are warned for; the problem here seems to be that the
829   type required for an array reference of this type is (INTEGER 0 (0))
830   which is canonicalized to NIL.
831
832 260:
833   a.
834   (let* ((s (gensym))
835          (t1 (specifier-type s)))
836     (eval `(defstruct ,s))
837     (type= t1 (specifier-type s)))
838   => NIL, NIL
839
840   (fixed in 0.8.1.24)
841
842   b. The same for CSUBTYPEP.
843
844 262: "yet another bug in inline expansion of local functions"
845   During inline expansion of a local function Python can try to
846   reference optimized away objects (functions, variables, CTRANs from
847   tags and blocks), which later may lead to problems. Some of the
848   cases are worked around by forbidding expansion in such cases, but
849   the better way would be to reimplement inline expansion by copying
850   IR1 structures.
851
852 266:
853   David Lichteblau provided (sbcl-devel 2003-06-01) a patch to fix
854   behaviour of streams with element-type (SIGNED-BYTE 8).  The patch
855   looks reasonable, if not obviously correct; however, it caused the
856   PPC/Linux port to segfault during warm-init while loading
857   src/pcl/std-class.fasl.  A workaround patch was made, but it would
858   be nice to understand why the first patch caused problems, and to
859   fix the cause if possible.
860
861 268: "wrong free declaration scope"
862   The following code must signal type error:
863
864     (locally (declare (optimize (safety 3)))
865       (flet ((foo (x &optional (y (car x)))
866                (declare (optimize (safety 0)))
867                (list x y)))
868         (funcall (eval #'foo) 1)))
869
870 270:
871   In the following function constraint propagator optimizes nothing:
872
873     (defun foo (x)
874       (declare (integer x))
875       (declare (optimize speed))
876       (typecase x
877         (fixnum "hala")
878         (fixnum "buba")
879         (bignum "hip")
880         (t "zuz")))
881
882 273:
883   Compilation of the following two forms causes "X is unbound" error:
884
885     (symbol-macrolet ((x pi))
886       (macrolet ((foo (y) (+ x y)))
887         (declaim (inline bar))
888         (defun bar (z)
889           (* z (foo 4)))))
890     (defun quux (z)
891       (bar z))
892
893   (See (COERCE (CDR X) 'FUNCTION) in IR1-CONVERT-INLINE-LAMBDA.)
894
895 274:
896   CLHS says that type declaration of a symbol macro should not affect
897   its expansion, but in SBCL it does. (If you like magic and want to
898   fix it, don't forget to change all uses of MACROEXPAND to
899   MACROEXPAND*.)
900
901 275:
902   The following code (taken from CLOCC) takes a lot of time to compile:
903
904     (defun foo (n)
905       (declare (type (integer 0 #.large-constant) n))
906       (expt 1/10 n))
907
908   (fixed in 0.8.2.51, but a test case would be good)
909
910 278:
911   a.
912     (defun foo ()
913       (declare (optimize speed))
914       (loop for i of-type (integer 0) from 0 by 2 below 10
915             collect i))
916
917   uses generic arithmetic.
918
919   b. (fixed in 0.8.3.6)
920
921 279: type propagation error -- correctly inferred type goes astray?
922   In sbcl-0.8.3 and sbcl-0.8.1.47, the warning
923        The binding of ABS-FOO is a (VALUES (INTEGER 0 0)
924        &OPTIONAL), not a (INTEGER 1 536870911)
925   is emitted when compiling this file:
926     (declaim (ftype (function ((integer 0 #.most-positive-fixnum))
927                               (integer #.most-negative-fixnum 0))
928                     foo))
929     (defun foo (x)
930       (- x))
931     (defun bar (x)
932       (let* (;; Uncomment this for a type mismatch warning indicating 
933              ;; that the type of (FOO X) is correctly understood.
934              #+nil (fs-foo (float-sign (foo x)))
935                    ;; Uncomment this for a type mismatch warning 
936                    ;; indicating that the type of (ABS (FOO X)) is
937                    ;; correctly understood.
938              #+nil (fs-abs-foo (float-sign (abs (foo x))))
939              ;; something wrong with this one though
940              (abs-foo (abs (foo x))))
941         (declare (type (integer 1 100) abs-foo))
942         (print abs-foo)))
943
944  (see also bug 117)
945
946 281: COMPUTE-EFFECTIVE-METHOD error signalling.
947   (slightly obscured by a non-0 default value for
948    SB-PCL::*MAX-EMF-PRECOMPUTE-METHODS*)
949   It would be natural for COMPUTE-EFFECTIVE-METHOD to signal errors
950   when it finds a method with invalid qualifiers.  However, it
951   shouldn't signal errors when any such methods are not applicable to
952   the particular call being evaluated, and certainly it shouldn't when
953   simply precomputing effective methods that may never be called.
954   (setf sb-pcl::*max-emf-precompute-methods* 0)
955   (defgeneric foo (x)
956     (:method-combination +)
957     (:method ((x symbol)) 1)
958     (:method + ((x number)) x))
959   (foo 1) -> ERROR, but should simply return 1
960
961   The issue seems to be that construction of a discriminating function
962   calls COMPUTE-EFFECTIVE-METHOD with methods that are not all applicable.
963
964 283: Thread safety: libc functions
965   There are places that we call unsafe-for-threading libc functions
966   that we should find alternatives for, or put locks around.  Known or
967   strongly suspected problems, as of 0.8.3.10: please update this
968   bug instead of creating new ones
969
970     localtime() - called for timezone calculations in code/time.lisp
971
972 284: Thread safety: special variables
973   There are lots of special variables in SBCL, and I feel sure that at
974   least some of them are indicative of potentially thread-unsafe 
975   parts of the system.  See doc/internals/notes/threading-specials
976
977 286: "recursive known functions"
978   Self-call recognition conflicts with known function
979   recognition. Currently cross compiler and target COMPILE do not
980   recognize recursion, and in target compiler it can be disabled. We
981   can always disable it for known functions with RECURSIVE attribute,
982   but there remains a possibility of a function with a
983   (tail)-recursive simplification pass and transforms/VOPs for base
984   cases.
985
986 287: PPC/Linux miscompilation or corruption in first GC
987   When the runtime is compiled with -O3 on certain PPC/Linux machines, a
988   segmentation fault is reported at the point of first triggered GC,
989   during the compilation of DEFSTRUCT WRAPPER.  As a temporary workaround,
990   the runtime is no longer compiled with -O3 on PPC/Linux, but it is likely
991   that this merely obscures, not solves, the underlying problem; as and when
992   underlying problems are fixed, it would be worth trying again to provoke
993   this problem.
994
995 288: fundamental cross-compilation issues (from old UGLINESS file)
996   Using host floating point numbers to represent target floating point
997   numbers, or host characters to represent target characters, is
998   theoretically shaky. (The characters are OK as long as the characters
999   are in the ANSI-guaranteed character set, though, so they aren't a
1000   real problem as long as the sources don't need anything but that;
1001   the floats are a real problem.)
1002
1003 289: "type checking and source-transforms"
1004   a.
1005     (block nil (let () (funcall #'+ (eval 'nil) (eval '1) (return :good))))
1006   signals type error.
1007
1008   Our policy is to check argument types at the moment of a call. It
1009   disagrees with ANSI, which says that type assertions are put
1010   immediately onto argument expressions, but is easier to implement in
1011   IR1 and is more compatible to type inference, inline expansion,
1012   etc. IR1-transforms automatically keep this policy, but source
1013   transforms for associative functions (such as +), being applied
1014   during IR1-convertion, do not. It may be tolerable for direct calls
1015   (+ x y z), but for (FUNCALL #'+ x y z) it is non-conformant.
1016
1017   b. Another aspect of this problem is efficiency. [x y + z +]
1018   requires less registers than [x y z + +]. This transformation is
1019   currently performed with source transforms, but it would be good to
1020   also perform it in IR1 optimization phase.
1021
1022 290: Alpha floating point and denormalized traps
1023   In SBCL 0.8.3.6x on the alpha, we work around what appears to be a
1024   hardware or kernel deficiency: the status of the enable/disable
1025   denormalized-float traps bit seems to be ambiguous; by the time we
1026   get to os_restore_fp_control after a trap, denormalized traps seem
1027   to be enabled.  Since we don't want a trap every time someone uses a
1028   denormalized float, in general, we mask out that bit when we restore
1029   the control word; however, this clobbers any change the user might
1030   have made.
1031
1032 296:
1033   (reported by Adam Warner, sbcl-devel 2003-09-23)
1034
1035   The --load toplevel argument does not perform any sanitization of its
1036   argument.  As a result, files with Lisp pathname pattern characters
1037   (#\* or #\?, for instance) or quotation marks can cause the system
1038   to perform arbitrary behaviour.
1039
1040 297:
1041   LOOP with non-constant arithmetic step clauses suffers from overzealous
1042   type constraint: code of the form 
1043     (loop for d of-type double-float from 0d0 to 10d0 by x collect d)
1044   compiles to a type restriction on X of (AND DOUBLE-FLOAT (REAL
1045   (0))).  However, an integral value of X should be legal, because
1046   successive adds of integers to double-floats produces double-floats,
1047   so none of the type restrictions in the code is violated.
1048
1049 300: (reported by Peter Graves) Function PEEK-CHAR checks PEEK-TYPE
1050   argument type only after having read a character. This is caused
1051   with EXPLICIT-CHECK attribute in DEFKNOWN. The similar problem
1052   exists with =, /=, <, >, <=, >=. They were fixed, but it is probably
1053   less error prone to have EXPLICIT-CHECK be a local declaration,
1054   being put into the definition, instead of an attribute being kept in
1055   a separate file; maybe also put it into SB-EXT?
1056
1057 301: ARRAY-SIMPLE-=-TYPE-METHOD breaks on corner cases which can arise
1058      in NOTE-ASSUMED-TYPES
1059   In sbcl-0.8.7.32, compiling the file
1060         (defun foo (x y)
1061           (declare (type integer x))
1062           (declare (type (vector (or hash-table bit)) y))
1063           (bletch 2 y))
1064         (defun bar (x y)
1065           (declare (type integer x))
1066           (declare (type (simple-array base (2)) y))
1067           (bletch 1 y))
1068   gives the error
1069     failed AVER: "(NOT (AND (NOT EQUALP) CERTAINP))"
1070
1071 303: "nonlinear LVARs" (aka MISC.293)
1072     (defun buu (x)
1073       (multiple-value-call #'list
1074         (block foo
1075           (multiple-value-prog1
1076               (eval '(values :a :b :c))
1077             (catch 'bar
1078               (if (> x 0)
1079                   (return-from foo
1080                     (eval `(if (> ,x 1)
1081                                1
1082                                (throw 'bar (values 3 4)))))))))))
1083
1084   (BUU 1) returns garbage.
1085
1086   The problem is that both EVALs sequentially write to the same LVAR.
1087
1088 305:
1089   (Reported by Dave Roberts.)
1090   Local INLINE/NOTINLINE declaration removes local FTYPE declaration:
1091
1092     (defun quux (x)
1093       (declare (ftype (function () (integer 0 10)) fee)
1094                (inline fee))
1095       (1+ (fee)))
1096
1097   uses generic arithmetic with INLINE and fixnum without.
1098
1099 306: "Imprecise unions of array types"
1100   a.(defun foo (x)
1101       (declare (optimize speed)
1102                (type (or (array cons) (array vector)) x))
1103       (elt (aref x 0) 0))
1104     (foo #((0))) => TYPE-ERROR
1105
1106   relatedly,
1107
1108   b.(subtypep 
1109      'array
1110      `(or
1111        ,@(loop for x across sb-vm:*specialized-array-element-type-properties*
1112                collect `(array ,(sb-vm:saetp-specifier x)))))
1113     => NIL, T (when it should be T, T)
1114
1115 309: "Dubious values for implementation limits"
1116     (reported by Bruno Haible sbcl-devel "Incorrect value of
1117     multiple-values-limit" 2004-04-19)
1118   (values-list (make-list 1000000)), on x86/linux, signals a stack
1119   exhaustion condition, despite MULTIPLE-VALUES-LIMIT being
1120   significantly larger than 1000000.  There are probably similar
1121   dubious values for CALL-ARGUMENTS-LIMIT (see cmucl-help/cmucl-imp
1122   around the same time regarding a call to LIST on sparc with 1000
1123   arguments) and other implementation limit constants.
1124
1125 311: "Tokeniser not thread-safe"
1126     (see also Robert Marlow sbcl-help "Multi threaded read chucking a
1127     spak" 2004-04-19)
1128   The tokenizer's use of *read-buffer* and *read-buffer-length* causes
1129   spurious errors should two threads attempt to tokenise at the same
1130   time.
1131
1132 314: "LOOP :INITIALLY clauses and scope of initializers"
1133   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1134   test suite, originally by Thomas F. Burdick.
1135     ;; <http://www.lisp.org/HyperSpec/Body/sec_6-1-7-2.html>
1136     ;; According to the HyperSpec 6.1.2.1.4, in for-as-equals-then, var is
1137     ;; initialized to the result of evaluating form1.  6.1.7.2 says that
1138     ;; initially clauses are evaluated in the loop prologue, which precedes all
1139     ;; loop code except for the initial settings provided by with, for, or as.
1140     (loop :for x = 0 :then (1+ x) 
1141           :for y = (1+ x) :then (ash y 1)
1142           :for z :across #(1 3 9 27 81 243) 
1143           :for w = (+ x y z)
1144           :initially (assert (zerop x)) :initially (assert (= 2 w))
1145           :until (>= w 100) :collect w)
1146     Expected: (2 6 15 38)
1147     Got:      ERROR
1148
1149 318: "stack overflow in compiler warning with redefined class"
1150   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1151   test suite.
1152     (defstruct foo a)
1153     (setf (find-class 'foo) nil)
1154     (defstruct foo slot-1)
1155   This used to give a stack overflow from within the printer, which has
1156   been fixed as of 0.8.16.11. Current result:
1157     ; caught ERROR:
1158     ;   can't compile TYPEP of anonymous or undefined class:
1159     ;     #<SB-KERNEL:STRUCTURE-CLASSOID FOO>
1160     ...
1161     debugger invoked on a TYPE-ERROR in thread 19973:
1162       The value NIL is not of type FUNCTION.
1163
1164   CSR notes: it's not really clear what it should give: is (SETF FIND-CLASS)
1165     meant to be enough to delete structure classes from the system?
1166
1167 319: "backquote with comma inside array"
1168   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1169   test suite.
1170     (read-from-string "`#1A(1 2 ,(+ 2 2) 4)") 
1171   gives
1172     #(1 2 ((SB-IMPL::|,|) + 2 2) 4)
1173   which probably isn't intentional.
1174
1175 323: "REPLACE, BIT-BASH and large strings"
1176   The transform for REPLACE on simple-base-strings uses BIT-BASH, which
1177   at present has an upper limit in size.  Consequently, in sbcl-0.8.10
1178     (defun foo ()
1179       (declare (optimize speed (safety 1)))
1180       (let ((x (make-string 140000000))
1181             (y (make-string 140000000)))
1182         (length (replace x y))))
1183     (foo)
1184   gives 
1185     debugger invoked on a TYPE-ERROR in thread 2412:
1186       The value 1120000000 is not of type (MOD 536870911).
1187   (see also "more and better sequence transforms" sbcl-devel 2004-05-10)
1188
1189 324: "STREAMs and :ELEMENT-TYPE with large bytesize"
1190   In theory, (open foo :element-type '(unsigned-byte <x>)) should work
1191   for all positive integral <x>.  At present, it only works for <x> up
1192   to about 1024 (and similarly for signed-byte), so
1193     (open "/dev/zero" :element-type '(unsigned-byte 1025))
1194   gives an error in sbcl-0.8.10.
1195
1196 325: "CLOSE :ABORT T on supeseding streams"
1197   Closing a stream opened with :IF-EXISTS :SUPERSEDE with :ABORT T leaves no
1198   file on disk, even if one existed before opening.
1199
1200   The illegality of this is not crystal clear, as the ANSI dictionary
1201   entry for CLOSE says that when :ABORT is T superseded files are not
1202   superseded (ie. the original should be restored), whereas the OPEN
1203   entry says about :IF-EXISTS :SUPERSEDE "If possible, the
1204   implementation should not destroy the old file until the new stream
1205   is closed." -- implying that even though undesirable, early deletion
1206   is legal. Restoring the original would none the less be the polite
1207   thing to do.
1208
1209 326: "*PRINT-CIRCLE* crosstalk between streams"
1210   In sbcl-0.8.10.48 it's possible for *PRINT-CIRCLE* references to be
1211   mixed between streams when output operations are intermingled closely
1212   enough (as by doing output on S2 from within (PRINT-OBJECT X S1) in the
1213   test case below), so that e.g. the references #2# appears on a stream
1214   with no preceding #2= on that stream to define it (because the #2= was
1215   sent to another stream).
1216     (cl:in-package :cl-user)
1217     (defstruct foo index)
1218     (defparameter *foo* (make-foo :index 4))
1219     (defstruct bar)
1220     (defparameter *bar* (make-bar))
1221     (defparameter *tangle* (list *foo* *bar* *foo*))
1222     (defmethod print-object ((foo foo) stream)
1223       (let ((index (foo-index foo)))
1224         (format *trace-output*
1225             "~&-$- emitting FOO ~D, ambient *BAR*=~S~%"
1226             index *bar*)
1227         (format stream "[FOO ~D]" index))
1228       foo)
1229     (let ((tsos (make-string-output-stream))
1230           (ssos (make-string-output-stream)))
1231       (let ((*print-circle* t)
1232             (*trace-output* tsos)
1233             (*standard-output* ssos))
1234         (prin1 *tangle* *standard-output*))
1235       (let ((string (get-output-stream-string ssos)))
1236         (unless (string= string "(#1=[FOO 4] #S(BAR) #1#)")
1237           ;; In sbcl-0.8.10.48 STRING was "(#1=[FOO 4] #2# #1#)".:-(
1238           (error "oops: ~S" string)))))
1239   It might be straightforward to fix this by turning the
1240   *CIRCULARITY-HASH-TABLE* and *CIRCULARITY-COUNTER* variables into
1241   per-stream slots, but (1) it would probably be sort of messy faking
1242   up the special variable binding semantics using UNWIND-PROTECT and
1243   (2) it might be sort of a pain to test that no other bugs had been
1244   introduced. 
1245
1246 328: "Profiling generic functions", transplanted from #241
1247   (from tonyms on #lisp IRC 2003-02-25)
1248   In sbcl-0.7.12.55, typing
1249     (defclass foo () ((bar :accessor foo-bar)))
1250     (profile foo-bar)
1251     (unintern 'foo-bar)
1252     (defclass foo () ((bar :accessor foo-bar)))
1253   gives the error message
1254     "#:FOO-BAR already names an ordinary function or a macro."
1255
1256   Problem: when a generic function is profiled, it appears as an ordinary
1257   function to PCL. (Remembering the uninterned accessor is OK, as the
1258   redefinition must be able to remove old accessors from their generic
1259   functions.)
1260
1261 329: "Sequential class redefinition"
1262   reported by Bruno Haible:
1263    (defclass reactor () ((max-temp :initform 10000000)))
1264    (defvar *r1* (make-instance 'reactor))
1265    (defvar *r2* (make-instance 'reactor))
1266    (slot-value *r1* 'max-temp)
1267    (slot-value *r2* 'max-temp)
1268    (defclass reactor () ((uptime :initform 0)))
1269    (slot-value *r1* 'uptime)
1270    (defclass reactor () ((uptime :initform 0) (max-temp :initform 10000)))
1271    (slot-value *r1* 'max-temp) ; => 10000
1272    (slot-value *r2* 'max-temp) ; => 10000000 oops...
1273
1274   Possible solution: 
1275    The method effective when the wrapper is obsoleted can be saved
1276      in the wrapper, and then to update the instance just run through
1277      all the old wrappers in order from oldest to newest.
1278
1279 332: "fasl stack inconsistency in structure redefinition"
1280   (reported by Tim Daly Jr sbcl-devel 2004-05-06)
1281   Even though structure redefinition is undefined by the standard, the
1282   following behaviour is suboptimal: running
1283     (defun stimulate-sbcl ()
1284       (let ((filename (format nil "/tmp/~A.lisp" (gensym))))
1285         ;;create a file which redefines a structure incompatibly
1286         (with-open-file (f filename :direction :output :if-exists :supersede)
1287           (print '(defstruct astruct foo) f)
1288           (print '(defstruct astruct foo bar) f))
1289         ;;compile and load the file, then invoke the continue restart on
1290         ;;the structure redefinition error
1291         (handler-bind ((error (lambda (c) (continue c))))
1292           (load (compile-file filename)))))
1293     (stimulate-sbcl)
1294   and choosing the CONTINUE restart yields the message
1295     debugger invoked on a SB-INT:BUG in thread 27726:
1296       fasl stack not empty when it should be
1297
1298 336: "slot-definitions must retain the generic functions of accessors"
1299   reported by Tony Martinez:
1300     (defclass foo () ((bar :reader foo-bar)))
1301     (defun foo-bar (x) x)
1302     (defclass foo () ((bar :reader get-bar))) ; => error, should work
1303
1304   Note: just punting the accessor removal if the fdefinition
1305   is not a generic function is not enough:
1306
1307    (defclass foo () ((bar :reader foo-bar)))
1308    (defvar *reader* #'foo-bar)
1309    (defun foo-bar (x) x)
1310    (defclass foo () ((bar :initform 'ok :reader get-bar)))
1311    (funcall *reader* (make-instance 'foo)) ; should be an error, since
1312                                            ; the method must be removed
1313                                            ; by the class redefinition
1314
1315   Fixing this should also fix a subset of #328 -- update the
1316   description with a new test-case then.
1317
1318 337: MAKE-METHOD and user-defined method classes
1319   (reported by Bruno Haible sbcl-devel 2004-06-11)
1320
1321   In the presence of  
1322
1323 (defclass user-method (standard-method) (myslot))
1324 (defmacro def-user-method (name &rest rest)
1325   (let* ((lambdalist-position (position-if #'listp rest))
1326          (qualifiers (subseq rest 0 lambdalist-position))
1327          (lambdalist (elt rest lambdalist-position))
1328          (body (subseq rest (+ lambdalist-position 1)))
1329          (required-part 
1330           (subseq lambdalist 0 (or 
1331                                 (position-if 
1332                                  (lambda (x) (member x lambda-list-keywords))
1333                                  lambdalist)
1334                                 (length lambdalist))))
1335          (specializers (mapcar #'find-class 
1336                                (mapcar (lambda (x) (if (consp x) (second x) t))
1337                                        required-part)))
1338          (unspecialized-required-part 
1339           (mapcar (lambda (x) (if (consp x) (first x) x)) required-part))
1340          (unspecialized-lambdalist 
1341           (append unspecialized-required-part 
1342            (subseq lambdalist (length required-part)))))
1343     `(PROGN
1344        (ADD-METHOD #',name
1345          (MAKE-INSTANCE 'USER-METHOD
1346           :QUALIFIERS ',qualifiers
1347           :LAMBDA-LIST ',unspecialized-lambdalist
1348           :SPECIALIZERS ',specializers
1349           :FUNCTION
1350           (LAMBDA (ARGUMENTS NEXT-METHODS-LIST)
1351             (FLET ((NEXT-METHOD-P () NEXT-METHODS-LIST)
1352                    (CALL-NEXT-METHOD (&REST NEW-ARGUMENTS)
1353                      (UNLESS NEW-ARGUMENTS (SETQ NEW-ARGUMENTS ARGUMENTS))
1354                      (IF (NULL NEXT-METHODS-LIST)
1355                          (ERROR "no next method for arguments ~:S" ARGUMENTS)
1356                          (FUNCALL (SB-PCL:METHOD-FUNCTION 
1357                                    (FIRST NEXT-METHODS-LIST))
1358                                   NEW-ARGUMENTS (REST NEXT-METHODS-LIST)))))
1359               (APPLY #'(LAMBDA ,unspecialized-lambdalist ,@body) ARGUMENTS)))))
1360        ',name)))
1361
1362   (progn
1363     (defgeneric test-um03 (x))
1364     (defmethod test-um03 ((x integer))
1365       (list* 'integer x (not (null (next-method-p))) (call-next-method)))
1366     (def-user-method test-um03 ((x rational))
1367       (list* 'rational x (not (null (next-method-p))) (call-next-method)))
1368     (defmethod test-um03 ((x real))
1369       (list 'real x (not (null (next-method-p)))))
1370     (test-um03 17))
1371   works, but
1372
1373   a.(progn
1374       (defgeneric test-um10 (x))
1375       (defmethod test-um10 ((x integer))
1376         (list* 'integer x (not (null (next-method-p))) (call-next-method)))
1377       (defmethod test-um10 ((x rational))
1378         (list* 'rational x (not (null (next-method-p))) (call-next-method)))
1379       (defmethod test-um10 ((x real))
1380         (list 'real x (not (null (next-method-p)))))
1381       (defmethod test-um10 :after ((x real)))
1382       (def-user-method test-um10 :around ((x integer))
1383         (list* 'around-integer x 
1384          (not (null (next-method-p))) (call-next-method)))
1385       (defmethod test-um10 :around ((x rational))
1386         (list* 'around-rational x 
1387          (not (null (next-method-p))) (call-next-method)))
1388       (defmethod test-um10 :around ((x real))
1389         (list* 'around-real x (not (null (next-method-p))) (call-next-method)))
1390       (test-um10 17))
1391     fails with a type error, and
1392
1393   b.(progn
1394       (defgeneric test-um12 (x))
1395       (defmethod test-um12 ((x integer))
1396         (list* 'integer x (not (null (next-method-p))) (call-next-method)))
1397       (defmethod test-um12 ((x rational))
1398         (list* 'rational x (not (null (next-method-p))) (call-next-method)))
1399       (defmethod test-um12 ((x real))
1400         (list 'real x (not (null (next-method-p)))))
1401       (defmethod test-um12 :after ((x real)))
1402       (defmethod test-um12 :around ((x integer))
1403         (list* 'around-integer x 
1404          (not (null (next-method-p))) (call-next-method)))
1405       (defmethod test-um12 :around ((x rational))
1406         (list* 'around-rational x 
1407          (not (null (next-method-p))) (call-next-method)))
1408       (def-user-method test-um12 :around ((x real))
1409         (list* 'around-real x (not (null (next-method-p))) (call-next-method)))
1410       (test-um12 17))
1411     fails with NO-APPLICABLE-METHOD.
1412
1413 339: "DEFINE-METHOD-COMBINATION bugs"
1414   (reported by Bruno Haible via the clisp test suite)
1415
1416   a. Syntax checking laxity (should produce errors):
1417      i. (define-method-combination foo :documentation :operator)
1418     ii. (define-method-combination foo :documentation nil)
1419    iii. (define-method-combination foo nil)
1420     iv. (define-method-combination foo nil nil
1421          (:arguments order &aux &key))
1422      v. (define-method-combination foo nil nil (:arguments &whole))
1423     vi. (define-method-combination foo nil nil (:generic-function))
1424    vii. (define-method-combination foo nil nil (:generic-function bar baz))
1425   viii. (define-method-combination foo nil nil (:generic-function (bar)))
1426     ix. (define-method-combination foo nil ((3)))
1427      x. (define-method-combination foo nil ((a)))
1428
1429   b. define-method-combination arguments lambda list badness
1430      i. &aux args are currently unsupported;
1431     ii. default values of &optional and &key arguments are ignored;
1432    iii. supplied-p variables for &optional and &key arguments are not
1433         bound.
1434
1435   c. qualifier matching incorrect
1436   (progn
1437     (define-method-combination mc27 () 
1438         ((normal ()) 
1439          (ignored (:ignore :unused)))
1440       `(list 'result 
1441              ,@(mapcar #'(lambda (method) `(call-method ,method)) normal)))
1442     (defgeneric test-mc27 (x)
1443       (:method-combination mc27)
1444       (:method :ignore ((x number)) (/ 0)))
1445     (test-mc27 7))
1446
1447   should signal an invalid-method-error, as the :IGNORE (NUMBER)
1448   method is applicable, and yet matches neither of the method group
1449   qualifier patterns.
1450
1451 341: PPRINT-LOGICAL-BLOCK / PPRINT-FILL / PPRINT-LINEAR sharing detection.
1452   (from Paul Dietz' test suite)
1453
1454   CLHS on PPRINT-LINEAR and PPRINT-FILL (and PPRINT-TABULAR, though
1455   that's slightly different) states that these functions perform
1456   circular and shared structure detection on their object.  Therefore,
1457
1458   a.(let ((*print-circle* t))
1459       (pprint-linear *standard-output* (let ((x '(a))) (list x x))))
1460     should print "(#1=(A) #1#)"
1461
1462   b.(let ((*print-circle* t))
1463       (pprint-linear *standard-output* 
1464                      (let ((x (cons nil nil))) (setf (cdr x) x) x)))
1465     should print "#1=(NIL . #1#)"
1466
1467   (it is likely that the fault lies in PPRINT-LOGICAL-BLOCK, as
1468   suggested by the suggested implementation of PPRINT-TABULAR)
1469
1470 343: MOP:COMPUTE-DISCRIMINATING-FUNCTION overriding causes error
1471   Even the simplest possible overriding of
1472   COMPUTE-DISCRIMINATING-FUNCTION, suggested in the PCL implementation
1473   as "canonical", does not work:
1474     (defclass my-generic-function (standard-generic-function) ()
1475       (:metaclass funcallable-standard-class))
1476     (defmethod compute-discriminating-function ((gf my-generic-function))
1477       (let ((dfun (call-next-method)))
1478         (lambda (&rest args)
1479           (apply dfun args))))
1480     (defgeneric foo (x)
1481       (:generic-function-class my-generic-function))
1482     (defmethod foo (x) (+ x x))
1483     (foo 5)
1484   signals an error.  This error is the same even if the LAMBDA is
1485   replaced by (FUNCTION (SB-KERNEL:INSTANCE-LAMBDA ...)).  Maybe the
1486   SET-FUNCALLABLE-INSTANCE-FUN scary stuff in
1487   src/code/target-defstruct.lisp is broken?  This seems to be broken
1488   in CMUCL 18e, so it's not caused by a recent change.
1489
1490 344: more (?) ROOM T problems (possibly part of bug 108)
1491   In sbcl-0.8.12.51, and off and on leading up to it, the
1492   SB!VM:MEMORY-USAGE operations in ROOM T caused 
1493         unhandled condition (of type SB-INT:BUG):
1494             failed AVER: "(SAP= CURRENT END)"
1495   Several clever people have taken a shot at this without fixing
1496   it; this time around (before sbcl-0.8.13 release) I (WHN) just
1497   commented out the SB!VM:MEMORY-USAGE calls until someone figures
1498   out how to make them work reliably with the rest of the GC.
1499
1500   (Note: there's at least one dubious thing in room.lisp: see the
1501   comment in VALID-OBJ)
1502
1503 346: alpha backtrace
1504   In sbcl-0.8.13, all backtraces from errors caused by internal errors
1505   on the alpha seem to have a "bogus stack frame".
1506
1507 349: PPRINT-INDENT rounding implementation decisions
1508   At present, pprint-indent (and indeed the whole pretty printer)
1509   more-or-less assumes that it's using a monospace font.  That's
1510   probably not too silly an assumption, but one piece of information
1511   the current implementation loses is from requests to indent by a
1512   non-integral amount.  As of sbcl-0.8.15.9, the system silently
1513   truncates the indentation to an integer at the point of request, but
1514   maybe the non-integral value should be propagated through the
1515   pprinter and only truncated at output?  (So that indenting by 1/2
1516   then 3/2 would indent by two spaces, not one?)
1517
1518 352: forward-referenced-class trouble
1519  reported by Bruno Haible on sbcl-devel
1520    (defclass c (a) ())
1521    (setf (class-name (find-class 'a)) 'b)
1522    (defclass a () (x))
1523    (defclass b () (y))
1524    (make-instance 'c)
1525  Expected: an instance of c, with a slot named x
1526  Got: debugger invoked on a SIMPLE-ERROR in thread 78906:
1527         While computing the class precedence list of the class named C.
1528         The class named B is a forward referenced class.
1529         The class named B is a direct superclass of the class named C.
1530
1531 353: debugger suboptimalities on x86
1532  On x86 backtraces for undefined functions start with a bogus stack
1533  frame, and  backtraces for throws to unknown catch tags with a "no 
1534  debug information" frame. These are both due to CODE-COMPONENT-FROM-BITS
1535  (used on non-x86 platforms) being a more complete solution then what
1536  is done on x86.
1537
1538  More generally, the debugger internals suffer from excessive x86/non-x86
1539  conditionalization and OAOOMization: refactoring the common parts would
1540  be good.
1541
1542 354: XEPs in backtraces
1543  Under default compilation policy
1544    (defun test ()
1545      (throw :unknown t))
1546    (test)
1547  Has the XEP for TEST in the backtrace, not the TEST frame itself.
1548  (sparc and x86 at least)
1549
1550 355: change-class of generic-function
1551     (reported by Bruno Haible)
1552   The MOP doesn't support change-class on a generic-function. However, SBCL
1553   apparently supports it, since it doesn't give an error or warning when doing
1554   so so. Then, however, it produces wrong results for calls to this generic 
1555   function.
1556   ;;; The effective-methods cache:
1557   (progn
1558     (defgeneric testgf35 (x))
1559     (defmethod testgf35 ((x integer))
1560       (cons 'integer (if (next-method-p) (call-next-method))))
1561     (defmethod testgf35 ((x real))
1562       (cons 'real (if (next-method-p) (call-next-method))))
1563     (defclass customized5-generic-function (standard-generic-function)
1564       ()
1565       (:metaclass sb-pcl:funcallable-standard-class))
1566     (defmethod sb-pcl:compute-effective-method ((gf customized5-generic-function) method-combination methods)
1567       `(REVERSE ,(call-next-method)))
1568     (list
1569       (testgf35 3)
1570       (progn
1571         (change-class #'testgf35 'customized5-generic-function)
1572         (testgf35 3))))
1573   Expected: ((INTEGER REAL) (REAL INTEGER))
1574   Got:      ((INTEGER REAL) (INTEGER REAL))
1575   ;;; The discriminating-function cache:
1576   (progn
1577     (defgeneric testgf36 (x))
1578     (defmethod testgf36 ((x integer))
1579       (cons 'integer (if (next-method-p) (call-next-method))))
1580     (defmethod testgf36 ((x real))
1581       (cons 'real (if (next-method-p) (call-next-method))))
1582     (defclass customized6-generic-function (standard-generic-function)
1583       ()
1584       (:metaclass sb-pcl:funcallable-standard-class))
1585     (defmethod sb-pcl:compute-discriminating-function ((gf customized6-generic-function))
1586       (let ((orig-df (call-next-method)))
1587         #'(lambda (&rest arguments)
1588             (reverse (apply orig-df arguments)))))
1589     (list
1590       (testgf36 3)
1591       (progn
1592         (change-class #'testgf36 'customized6-generic-function)
1593         (testgf36 3))))
1594   Expected: ((INTEGER REAL) (REAL INTEGER))
1595   Got:      ((INTEGER REAL) (INTEGER REAL))
1596
1597 356: PCL corruption
1598     (reported by Bruno Haible)
1599   After the "layout depth conflict" error, the CLOS is left in a state where
1600   it's not possible to define new standard-class subclasses any more.
1601   Test case:
1602   (defclass prioritized-dispatcher ()
1603     ((dependents :type list :initform nil)))
1604   (defmethod sb-pcl:validate-superclass ((c1 sb-pcl:funcallable-standard-class) 
1605                                          (c2 (eql (find-class 'prioritized-dispatcher))))
1606     t)
1607   (defclass prioritized-generic-function (prioritized-dispatcher standard-generic-function)
1608     ()
1609     (:metaclass sb-pcl:funcallable-standard-class))
1610   ;; ERROR, Quit the debugger with ABORT
1611   (defclass typechecking-reader-class (standard-class)
1612     ())
1613   Expected: #<STANDARD-CLASS TYPECHECKING-READER-CLASS>
1614   Got:      ERROR "The assertion SB-PCL::WRAPPERS failed."
1615
1616 357: defstruct inheritance of initforms
1617     (reported by Bruno Haible)
1618   When defstruct and defclass (with :metaclass structure-class) are mixed,
1619   1. some slot initforms are ignored by the DEFSTRUCT generated constructor
1620      function, and 
1621   2. all slot initforms are ignored by MAKE-INSTANCE. (This can be arguably
1622      OK for initforms that were given in a DEFSTRUCT form, but for those
1623      given in a DEFCLASS form, I think it qualifies as a bug.)
1624   Test case:
1625   (defstruct structure02a
1626     slot1
1627     (slot2 t)
1628     (slot3 (floor pi)))
1629   (defclass structure02b (structure02a)
1630     ((slot4 :initform -44)
1631      (slot5)
1632      (slot6 :initform t)
1633      (slot7 :initform (floor (* pi pi)))
1634      (slot8 :initform 88))
1635     (:metaclass structure-class))
1636   (defstruct (structure02c (:include structure02b (slot8 -88)))
1637     slot9 
1638     (slot10 t)
1639     (slot11 (floor (exp 3))))
1640   ;; 1. Form:
1641   (let ((a (make-structure02c)))
1642     (list (structure02c-slot4 a)
1643           (structure02c-slot5 a)
1644           (structure02c-slot6 a)
1645           (structure02c-slot7 a)))
1646   Expected: (-44 nil t 9)
1647   Got: (SB-PCL::..SLOT-UNBOUND.. SB-PCL::..SLOT-UNBOUND..
1648         SB-PCL::..SLOT-UNBOUND.. SB-PCL::..SLOT-UNBOUND..)
1649   ;; 2. Form:
1650   (let ((b (make-instance 'structure02c)))
1651     (list (structure02c-slot2 b)
1652           (structure02c-slot3 b)
1653           (structure02c-slot4 b)
1654           (structure02c-slot6 b)
1655           (structure02c-slot7 b)
1656           (structure02c-slot8 b)
1657           (structure02c-slot10 b)
1658           (structure02c-slot11 b)))
1659   Expected: (t 3 -44 t 9 -88 t 20)
1660   Got: (0 0 0 0 0 0 0 0)
1661
1662 358: :DECLARE argument to ENSURE-GENERIC-FUNCTION 
1663     (reported by Bruno Haible)
1664   According to ANSI CL, ensure-generic-function must accept a :DECLARE
1665   keyword argument. In SBCL 0.8.16 it does not.
1666   Test case:
1667   (progn
1668     (ensure-generic-function 'foo113 :declare '((optimize (speed 3))))
1669     (sb-pcl:generic-function-declarations #'foo113))
1670   Expected: ((OPTIMIZE (SPEED 3)))
1671   Got: ERROR
1672     Invalid initialization argument:
1673       :DECLARE
1674     in call for class #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>.
1675   See also:
1676     The ANSI Standard, Section 7.1.2
1677
1678   Bruno notes: The MOP specifies that ensure-generic-function accepts :DECLARATIONS.
1679   The easiest way to be compliant to both specs is to accept both (exclusively
1680   or cumulatively).
1681
1682 359: wrong default value for ensure-generic-function's :generic-function-class argument
1683     (reported by Bruno Haible)
1684   ANSI CL is silent on this, but the MOP's specification of ENSURE-GENERIC-FUNCTION says:
1685    "The remaining arguments are the complete set of keyword arguments
1686     received by ENSURE-GENERIC-FUNCTION."
1687   and the spec of ENSURE-GENERIC-FUNCTION-USING-CLASS:
1688    ":GENERIC-FUNCTION-CLASS - a class metaobject or a class name. If it is not
1689     supplied, it defaults to the class named STANDARD-GENERIC-FUNCTION."
1690   This is not the case in SBCL. Test case:
1691    (defclass my-generic-function (standard-generic-function)
1692      ()
1693      (:metaclass sb-pcl:funcallable-standard-class))
1694    (setf (fdefinition 'foo1)
1695          (make-instance 'my-generic-function :name 'foo1))
1696    (ensure-generic-function 'foo1
1697      :generic-function-class (find-class 'standard-generic-function))
1698    (class-of #'foo1)
1699    ; => #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>
1700    (setf (fdefinition 'foo2)
1701          (make-instance 'my-generic-function :name 'foo2))
1702    (ensure-generic-function 'foo2)
1703    (class-of #'foo2)
1704   Expected: #<SB-MOP:FUNCALLABLE-STANDARD-CLASS STANDARD-GENERIC-FUNCTION>
1705   Got:      #<SB-MOP:FUNCALLABLE-STANDARD-CLASS MY-GENERIC-FUNCTION>
1706
1707 360: CALL-METHOD not recognized in method-combination body
1708   (reported by Bruno Haible)
1709   This method combination, which adds 'redo' and 'return' restarts for each
1710   method invocation to standard method combination, gives an error in SBCL.
1711   (defun prompt-for-new-values ()
1712     (format *debug-io* "~&New values: ")
1713     (list (read *debug-io*)))
1714   (defun add-method-restarts (form method)
1715     (let ((block (gensym))
1716           (tag (gensym)))
1717       `(BLOCK ,block
1718          (TAGBODY
1719            ,tag
1720            (RETURN-FROM ,block
1721              (RESTART-CASE ,form
1722                (METHOD-REDO ()
1723                  :REPORT (LAMBDA (STREAM) (FORMAT STREAM "Try calling ~S again." ,method))
1724                  (GO ,tag))
1725                (METHOD-RETURN (L)
1726                  :REPORT (LAMBDA (STREAM) (FORMAT STREAM "Specify return values for ~S call." ,method))
1727                  :INTERACTIVE (LAMBDA () (PROMPT-FOR-NEW-VALUES))
1728                  (RETURN-FROM ,block (VALUES-LIST L)))))))))
1729   (defun convert-effective-method (efm)
1730     (if (consp efm)
1731       (if (eq (car efm) 'CALL-METHOD)
1732         (let ((method-list (third efm)))
1733           (if (or (typep (first method-list) 'method) (rest method-list))
1734             ; Reduce the case of multiple methods to a single one.
1735             ; Make the call to the next-method explicit.
1736             (convert-effective-method
1737               `(CALL-METHOD ,(second efm)
1738                  ((MAKE-METHOD
1739                     (CALL-METHOD ,(first method-list) ,(rest method-list))))))
1740             ; Now the case of at most one method.
1741             (if (typep (second efm) 'method)
1742               ; Wrap the method call in a RESTART-CASE.
1743               (add-method-restarts
1744                 (cons (convert-effective-method (car efm))
1745                       (convert-effective-method (cdr efm)))
1746                 (second efm))
1747               ; Normal recursive processing.
1748               (cons (convert-effective-method (car efm))
1749                     (convert-effective-method (cdr efm))))))
1750         (cons (convert-effective-method (car efm))
1751               (convert-effective-method (cdr efm))))
1752       efm))
1753   (define-method-combination standard-with-restarts ()
1754          ((around (:around))
1755           (before (:before))
1756           (primary () :required t)
1757           (after (:after)))
1758     (flet ((call-methods-sequentially (methods)
1759              (mapcar #'(lambda (method)
1760                          `(CALL-METHOD ,method))
1761                      methods)))
1762       (let ((form (if (or before after (rest primary))
1763                     `(MULTIPLE-VALUE-PROG1
1764                        (PROGN
1765                          ,@(call-methods-sequentially before)
1766                          (CALL-METHOD ,(first primary) ,(rest primary)))
1767                        ,@(call-methods-sequentially (reverse after)))
1768                     `(CALL-METHOD ,(first primary)))))
1769         (when around
1770           (setq form
1771                 `(CALL-METHOD ,(first around)
1772                               (,@(rest around) (MAKE-METHOD ,form)))))
1773         (convert-effective-method form))))
1774   (defgeneric testgf16 (x) (:method-combination standard-with-restarts))
1775   (defclass testclass16a () ())
1776   (defclass testclass16b (testclass16a) ())
1777   (defclass testclass16c (testclass16a) ())
1778   (defclass testclass16d (testclass16b testclass16c) ())
1779   (defmethod testgf16 ((x testclass16a))
1780     (list 'a
1781           (not (null (find-restart 'method-redo)))
1782           (not (null (find-restart 'method-return)))))
1783   (defmethod testgf16 ((x testclass16b))
1784     (cons 'b (call-next-method)))
1785   (defmethod testgf16 ((x testclass16c))
1786     (cons 'c (call-next-method)))
1787   (defmethod testgf16 ((x testclass16d))
1788     (cons 'd (call-next-method)))
1789   (testgf16 (make-instance 'testclass16d))
1790
1791   Expected: (D B C A T T)
1792   Got: ERROR CALL-METHOD outside of a effective method form
1793
1794   This is a bug because ANSI CL HyperSpec/Body/locmac_call-m__make-method
1795   says
1796    "The macro call-method invokes the specified method, supplying it with
1797     arguments and with definitions for call-next-method and for next-method-p.
1798     If the invocation of call-method is lexically inside of a make-method,
1799     the arguments are those that were supplied to that method. Otherwise
1800     the arguments are those that were supplied to the generic function."
1801   and the example uses nothing more than these two cases (as you can see by
1802   doing (trace convert-effective-method)).
1803
1804 361: initialize-instance of standard-reader-method ignores :function argument
1805     (reported by Bruno Haible)
1806   Pass a custom :function argument to initialize-instance of a
1807   standard-reader-method instance, but it has no effect.
1808   ;; Check that it's possible to define reader methods that do typechecking.
1809   (progn
1810     (defclass typechecking-reader-method (sb-pcl:standard-reader-method)
1811       ())
1812     (defmethod initialize-instance ((method typechecking-reader-method) &rest initargs
1813                                     &key slot-definition)
1814       (let ((name (sb-pcl:slot-definition-name slot-definition))
1815             (type (sb-pcl:slot-definition-type slot-definition)))
1816         (apply #'call-next-method method
1817                :function #'(lambda (args next-methods)
1818                              (declare (ignore next-methods))
1819                              (apply #'(lambda (instance)
1820                                         (let ((value (slot-value instance name)))
1821                                           (unless (typep value type)
1822                                             (error "Slot ~S of ~S is not of type ~S: ~S"
1823                                                    name instance type value))
1824                                           value))
1825                                     args))
1826                initargs)))
1827     (defclass typechecking-reader-class (standard-class)
1828       ())
1829     (defmethod sb-pcl:validate-superclass ((c1 typechecking-reader-class) (c2 standard-class))
1830       t)
1831     (defmethod reader-method-class ((class typechecking-reader-class) direct-slot &rest args)
1832       (find-class 'typechecking-reader-method))
1833     (defclass testclass25 ()
1834       ((pair :type (cons symbol (cons symbol null)) :initarg :pair :accessor testclass25-pair))
1835       (:metaclass typechecking-reader-class))
1836    (macrolet ((succeeds (form)
1837                  `(not (nth-value 1 (ignore-errors ,form)))))
1838       (let ((p (list 'abc 'def))
1839             (x (make-instance 'testclass25)))
1840         (list (succeeds (make-instance 'testclass25 :pair '(seventeen 17)))
1841               (succeeds (setf (testclass25-pair x) p))
1842               (succeeds (setf (second p) 456))
1843               (succeeds (testclass25-pair x))
1844               (succeeds (slot-value x 'pair))))))
1845   Expected: (t t t nil t)
1846   Got:      (t t t t t)
1847
1848   (inspect (first (sb-pcl:generic-function-methods #'testclass25-pair)))
1849   shows that the method was created with a FAST-FUNCTION slot but with a
1850   FUNCTION slot of NIL.
1851
1852 362: missing error when a slot-definition is created without a name
1853     (reported by Bruno Haible)
1854   The MOP says about slot-definition initialization:
1855   "The :NAME argument is a slot name. An ERROR is SIGNALled if this argument
1856    is not a symbol which can be used as a variable name. An ERROR is SIGNALled
1857    if this argument is not supplied."
1858   Test case:
1859    (make-instance (find-class 'sb-pcl:standard-direct-slot-definition))
1860   Expected: ERROR
1861   Got: #<SB-MOP:STANDARD-DIRECT-SLOT-DEFINITION NIL>
1862
1863 363: missing error when a slot-definition is created with a wrong documentation object
1864     (reported by Bruno Haible)
1865   The MOP says about slot-definition initialization:
1866   "The :DOCUMENTATION argument is a STRING or NIL. An ERROR is SIGNALled
1867    if it is not. This argument default to NIL during initialization."
1868   Test case:
1869    (make-instance (find-class 'sb-pcl:standard-direct-slot-definition)
1870                   :name 'foo
1871                   :documentation 'not-a-string)
1872   Expected: ERROR
1873   Got: #<SB-MOP:STANDARD-DIRECT-SLOT-DEFINITION FOO>
1874
1875 364: does not support class objects as specializer names
1876    (reported by Bruno Haible)
1877   According to ANSI CL 7.6.2, class objects are valid specializer names,
1878   and "Parameter specializer names are used in macros intended as the
1879   user-level interface (defmethod)". DEFMETHOD's syntax section doesn't
1880   mention this possibility in the BNF for parameter-specializer-name;
1881   however, this appears to be an editorial omission, since the CLHS
1882   mentions issue CLASS-OBJECT-SPECIALIZER:AFFIRM as being approved
1883   by X3J13. SBCL doesn't support it:
1884    (defclass foo () ())
1885    (defmethod goo ((x #.(find-class 'foo))) x)
1886   Expected: #<STANDARD-METHOD GOO (#<STANDARD-CLASS FOO>)>
1887   Got:      ERROR "#<STANDARD-CLASS FOO> is not a legal class name."
1888
1889 365: mixin on generic-function subclass
1890     (reported by Bruno Haible)
1891   a mixin class
1892     (defclass prioritized-dispatcher ()
1893       ((dependents :type list :initform nil)))
1894   on a generic-function subclass:
1895     (defclass prioritized-generic-function (prioritized-dispatcher standard-generic-function)
1896       ()
1897       (:metaclass sb-pcl:funcallable-standard-class))
1898   SBCL gives an error on this, telling to define a method on SB-MOP:VALIDATE-SUPERCLASS. If done,
1899     (defmethod sb-pcl:validate-superclass ((c1 sb-pcl:funcallable-standard-class) 
1900                                            (c2 (eql (find-class 'prioritized-dispatcher))))
1901       t)
1902   then, however,
1903     (defclass prioritized-generic-function (prioritized-dispatcher standard-generic-function)
1904       ()
1905       (:metaclass sb-pcl:funcallable-standard-class))
1906   => debugger invoked on a SIMPLE-ERROR in thread 6687:
1907     layout depth conflict: #(#<SB-KERNEL:LAYOUT for T {500E1E9}> ...)
1908  
1909   Further discussion on this: http://thread.gmane.org/gmane.lisp.steel-bank.general/491
1910
1911 366: cannot define two generic functions with user-defined class
1912    (reported by Bruno Haible)
1913   it is possible to define one generic function class and an instance
1914   of it. But attempting to do the same thing again, in the same session,
1915   leads to a "Control stack exhausted" error. Test case:
1916     (defclass my-generic-function-1 (standard-generic-function)
1917       ()
1918       (:metaclass sb-pcl:funcallable-standard-class))
1919     (defgeneric testgf-1 (x) (:generic-function-class my-generic-function-1)
1920       (:method ((x integer)) (cons 'integer nil)))
1921     (defclass my-generic-function-2 (standard-generic-function)
1922       ()
1923       (:metaclass sb-pcl:funcallable-standard-class))
1924     (defgeneric testgf-2 (x) (:generic-function-class my-generic-function-2)
1925       (:method ((x integer)) (cons 'integer nil)))
1926   => SB-KERNEL::CONTROL-STACK-EXHAUSTED
1927
1928 367: TYPE-ERROR at compile time, undetected TYPE-ERROR at runtime
1929   This test program
1930     (declaim (optimize (safety 3) (debug 2) (speed 2) (space 1)))
1931     (defstruct e367)
1932     (defstruct i367)
1933     (defstruct g367
1934       (i367s (make-array 0 :fill-pointer t) :type (or (vector i367) null)))
1935     (defstruct s367
1936       (g367 (error "missing :G367") :type g367 :read-only t))
1937     ;;; In sbcl-0.8.18, commenting out this (DECLAIM (FTYPE ... R367))
1938     ;;; gives an internal error at compile time:
1939     ;;;    The value #<SB-KERNEL:NAMED-TYPE NIL> is not of
1940     ;;;    type SB-KERNEL:VALUES-TYPE.
1941     (declaim (ftype (function ((vector i367) e367) (or s367 null)) r367))
1942     (declaim (ftype (function ((vector e367)) (values)) h367))
1943     (defun frob (v w)
1944       (let ((x (g367-i367s (make-g367))))
1945         (let* ((y (or (r367 x w)
1946                       (h367 x)))
1947                (z (s367-g367 y)))
1948           (format t "~&Y=~S Z=~S~%" y z)
1949           (g367-i367s z))))
1950     (defun r367 (x y) (declare (ignore x y)) nil)
1951     (defun h367 (x) (declare (ignore x)) (values))
1952     ;;; In sbcl-0.8.18, executing this form causes an low-level error
1953     ;;;   segmentation violation at #X9B0E1F4
1954     ;;; (instead of the TYPE-ERROR that one might like).
1955     (frob 0 (make-e367))
1956   can be made to cause two different problems, as noted in the comments:
1957     bug 367a: Compile and load the file. No TYPE-ERROR is signalled at 
1958       run time (in the (S367-G367 Y) form of FROB, when Y is NIL 
1959       instead of an instance of S367). Instead (on x86/Linux at least)
1960       we end up with a segfault.
1961     bug 367b: Comment out the (DECLAIM (FTYPE ... R367)), and compile 
1962       the file. The compiler fails with TYPE-ERROR at compile time.
1963
1964 368: miscompiled OR (perhaps related to bug 367)
1965   Trying to relax type declarations to find a workaround for bug 367,
1966   it turns out that even when the return type isn't declared (or 
1967   declared to be T, anyway) the system remains confused about type 
1968   inference in code similar to that for bug 367:
1969     (in-package :cl-user)
1970     (declaim (optimize (safety 3) (debug 2) (speed 2) (space 1)))
1971     (defstruct e368)
1972     (defstruct i368)
1973     (defstruct g368
1974       (i368s (make-array 0 :fill-pointer t) :type (or (vector i368) null)))
1975     (defstruct s368
1976       (g368 (error "missing :G368") :type g368 :read-only t))
1977     (declaim (ftype (function (fixnum (vector i368) e368) t) r368))
1978     (declaim (ftype (function (fixnum (vector e368)) t) h368))
1979     (defparameter *h368-was-called-p* nil)
1980     (defun nsu (vertices e368)
1981       (let ((i368s (g368-i368s (make-g368))))
1982         (let ((fuis (r368 0 i368s e368)))
1983           (format t "~&FUIS=~S~%" fuis)
1984           (or fuis (h368 0 i368s)))))
1985     (defun r368 (w x y)
1986       (declare (ignore w x y))
1987       nil)
1988     (defun h368 (w x)
1989       (declare (ignore w x))
1990       (setf *h368-was-called-p* t)
1991       (make-s368 :g368 (make-g368)))
1992     (trace r368 h368)
1993     (format t "~&calling NSU~%")
1994     (let ((nsu (nsu #() (make-e368))))
1995       (format t "~&NSU returned ~S~%" nsu)
1996       (format t "~&*H368-WAS-CALLED-P*=~S~%" *h368-was-called-p*)
1997       (assert (s368-p nsu))
1998       (assert *h368-was-called-p*))
1999   In sbcl-0.8.18, both ASSERTs fail, and (DISASSEMBLE 'NSU) shows
2000   that no call to H368 is compiled.
2001
2002 369: unlike-an-intersection behavior of VALUES-TYPE-INTERSECTION
2003   In sbcl-0.8.18.2, the identity $(x \cap y \cap y)=(x \cap y)$ 
2004   does not hold for VALUES-TYPE-INTERSECTION, even for types which
2005   can be intersected exactly, so that ASSERTs fail in this test case:
2006     (in-package :cl-user)
2007     (let ((types (mapcar #'sb-c::values-specifier-type 
2008                          '((values (vector package) &optional)
2009                            (values (vector package) &rest t)
2010                            (values (vector hash-table) &rest t)
2011                            (values (vector hash-table) &optional)
2012                            (values t &optional)
2013                            (values t &rest t)
2014                            (values nil &optional)
2015                            (values nil &rest t)
2016                            (values sequence &optional)
2017                            (values sequence &rest t)
2018                            (values list &optional)
2019                            (values list &rest t)))))
2020        (dolist (x types)
2021          (dolist (y types)
2022            (let ((i (sb-c::values-type-intersection x y)))
2023              (assert (sb-c::type= i (sb-c::values-type-intersection i x)))
2024              (assert (sb-c::type= i (sb-c::values-type-intersection i y)))))))
2025
2026 370: reader misbehaviour on large-exponent floats
2027     (read-from-string "1.0s1000000000000000000000000000000000000000")
2028   causes the reader to attempt to create a very large bignum (which it
2029   will then attempt to coerce to a rational).  While this isn't
2030   completely wrong, it is probably not ideal -- checking the floating
2031   point control word state and then returning the relevant float
2032   (most-positive-short-float or short-float-infinity) or signalling an
2033   error immediately would seem to make more sense.
2034
2035 372: floating-point overflow not signalled on ppc/darwin
2036  The following assertions in float.pure.lisp fail on ppc/darwin 
2037  (Mac OS X version 10.3.7):
2038    (assert (raises-error? (scale-float 1.0 most-positive-fixnum)
2039                           floating-point-overflow))
2040    (assert (raises-error? (scale-float 1.0d0 (1+ most-positive-fixnum))
2041                           floating-point-overflow)))
2042  as the SCALE-FLOAT just returns 
2043  #.SB-EXT:SINGLE/DOUBLE-FLOAT-POSITIVE-INFINITY. These tests have been
2044  disabled on Darwin for now.
2045
2046 373: profiling issues on ppc/darwin
2047  The following bit from smoke.impure.lisp fails on ppc/darwin:
2048     (progn
2049       (defun profiled-fun ()
2050         (random 1d0))
2051       (profile profiled-fun)
2052       (loop repeat 100000 do (profiled-fun))
2053       (report))
2054  dropping into the debugger with a TYPE-ERROR:
2055     The value -1073741382 is not of type UNSIGNED-BYTE.
2056  The test has been disabled on Darwin till the bug is fixed.
2057
2058 374: BIT-AND problem on ppc/darwin:
2059   The BIT-AND test in bit-vector.impure-cload.lisp results in
2060     fatal error encountered in SBCL pid 8356:
2061     GC invariant lost, file "gc-common.c", line 605
2062   on ppc/darwin. Test disabled for the duration.