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