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