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