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