0.8.10.75:
[sbcl.git] / BUGS
1 REPORTING BUGS
2
3 Bugs can be reported on the help mailing list
4   sbcl-help@lists.sourceforge.net
5 or on the development mailing list
6   sbcl-devel@lists.sourceforge.net
7
8 Please include enough information in a bug report that someone reading
9 it can reproduce the problem, i.e. don't write
10      Subject: apparent bug in PRINT-OBJECT (or *PRINT-LENGTH*?)
11      PRINT-OBJECT doesn't seem to work with *PRINT-LENGTH*. Is this a bug?
12 but instead
13      Subject: apparent bug in PRINT-OBJECT (or *PRINT-LENGTH*?)
14      In sbcl-1.2.3 running under OpenBSD 4.5 on my Alpha box, when
15      I compile and load the file
16        (DEFSTRUCT (FOO (:PRINT-OBJECT (LAMBDA (X Y)
17                                         (LET ((*PRINT-LENGTH* 4))
18                                           (PRINT X Y)))))
19          X Y)
20      then at the command line type
21        (MAKE-FOO)
22      the program loops endlessly instead of printing the object.
23
24
25 NOTES:
26
27 There is also some information on bugs in the manual page and
28 in the TODO file. Eventually more such information may move here.
29
30 The gaps in the number sequence belong to old bug descriptions which
31 have gone away (typically because they were fixed, but sometimes for
32 other reasons, e.g. because they were moved elsewhere).
33
34
35 2:
36   DEFSTRUCT almost certainly should overwrite the old LAYOUT information
37   instead of just punting when a contradictory structure definition
38   is loaded. As it is, if you redefine DEFSTRUCTs in a way which 
39   changes their layout, you probably have to rebuild your entire
40   program, even if you know or guess enough about the internals of
41   SBCL to wager that this (undefined in ANSI) operation would be safe.
42
43 3: "type checking of structure slots"
44   a:
45   ANSI specifies that a type mismatch in a structure slot
46   initialization value should not cause a warning.
47 WORKAROUND:
48   This one might not be fixed for a while because while we're big
49   believers in ANSI compatibility and all, (1) there's no obvious
50   simple way to do it (short of disabling all warnings for type
51   mismatches everywhere), and (2) there's a good portable
52   workaround, and (3) by their own reasoning, it looks as though
53   ANSI may have gotten it wrong. ANSI justifies this specification
54   by saying 
55     The restriction against issuing a warning for type mismatches
56     between a slot-initform and the corresponding slot's :TYPE
57     option is necessary because a slot-initform must be specified
58     in order to specify slot options; in some cases, no suitable
59     default may exist.
60   However, in SBCL (as in CMU CL or, for that matter, any compiler
61   which really understands Common Lisp types) a suitable default
62   does exist, in all cases, because the compiler understands the
63   concept of functions which never return (i.e. has return type NIL).
64   Thus, as a portable workaround, you can use a call to some
65   known-never-to-return function as the default. E.g.
66     (DEFSTRUCT FOO
67       (BAR (ERROR "missing :BAR argument")
68            :TYPE SOME-TYPE-TOO-HAIRY-TO-CONSTRUCT-AN-INSTANCE-OF))
69   or 
70     (DECLAIM (FTYPE (FUNCTION () NIL) MISSING-ARG))
71     (DEFUN REQUIRED-ARG () ; workaround for SBCL non-ANSI slot init typing
72       (ERROR "missing required argument")) 
73     (DEFSTRUCT FOO
74       (BAR (REQUIRED-ARG) :TYPE TRICKY-TYPE-OF-SOME-SORT)
75       (BLETCH (REQUIRED-ARG) :TYPE TRICKY-TYPE-OF-SOME-SORT)
76       (N-REFS-SO-FAR 0 :TYPE (INTEGER 0)))
77   Such code should compile without complaint and work correctly either
78   on SBCL or on any other completely compliant Common Lisp system.
79
80   b: &AUX argument in a boa-constructor without a default value means
81      "do not initilize this slot" and does not cause type error. But
82      an error may be signalled at read time and it would be good if
83      SBCL did it.
84
85   d: (fixed in 0.8.1.5)
86
87 7:
88   The "compiling top-level form:" output ought to be condensed.
89   Perhaps any number of such consecutive lines ought to turn into a
90   single "compiling top-level forms:" line.
91
92 19:
93   (I *think* this is a bug. It certainly seems like strange behavior. But
94   the ANSI spec is scary, dark, and deep.. -- WHN)
95     (FORMAT NIL  "~,1G" 1.4) => "1.    "
96     (FORMAT NIL "~3,1G" 1.4) => "1.    "
97
98 27:
99   Sometimes (SB-EXT:QUIT) fails with 
100         Argh! maximum interrupt nesting depth (4096) exceeded, exiting
101         Process inferior-lisp exited abnormally with code 1
102   I haven't noticed a repeatable case of this yet.
103
104 32:
105   The printer doesn't report closures very well. This is true in 
106   CMU CL 18b as well:
107     (PRINT #'CLASS-NAME)
108   gives
109     #<Closure Over Function "DEFUN STRUCTURE-SLOT-ACCESSOR" {134D1A1}>
110   It would be nice to make closures have a settable name slot,
111   and make things like DEFSTRUCT and FLET, which create closures,
112   set helpful values into this slot.
113
114 33:
115   And as long as we're wishing, it would be awfully nice if INSPECT could
116   also report on closures, telling about the values of the bound variables.
117
118 35:
119   The compiler assumes that any time a function of declared FTYPE
120   doesn't signal an error, its arguments were of the declared type.
121   E.g. compiling and loading
122     (DECLAIM (OPTIMIZE (SAFETY 3)))
123     (DEFUN FACTORIAL (X) (GAMMA (1+ X)))
124     (DEFUN GAMMA (X) X)
125     (DECLAIM (FTYPE (FUNCTION (UNSIGNED-BYTE)) FACTORIAL))
126     (DEFUN FOO (X)
127       (COND ((> (FACTORIAL X) 1.0E6)
128              (FORMAT T "too big~%"))
129             ((INTEGERP X)
130              (FORMAT T "exactly ~S~%" (FACTORIAL X)))
131             (T
132              (FORMAT T "approximately ~S~%" (FACTORIAL X)))))
133   then executing
134     (FOO 1.5)
135   will cause the INTEGERP case to be selected, giving bogus output a la
136     exactly 2.5
137   This violates the "declarations are assertions" principle.
138   According to the ANSI spec, in the section "System Class FUNCTION",
139   this is a case of "lying to the compiler", but the lying is done
140   by the code which calls FACTORIAL with non-UNSIGNED-BYTE arguments,
141   not by the unexpectedly general definition of FACTORIAL. In any case,
142   "declarations are assertions" means that lying to the compiler should
143   cause an error to be signalled, and should not cause a bogus
144   result to be returned. Thus, the compiler should not assume
145   that arbitrary functions check their argument types. (It might
146   make sense to add another flag (CHECKED?) to DEFKNOWN to 
147   identify functions which *do* check their argument types.)
148   (Also, verify that the compiler handles declared function
149   return types as assertions.)
150
151 42:
152   The definitions of SIGCONTEXT-FLOAT-REGISTER and
153   %SET-SIGCONTEXT-FLOAT-REGISTER in x86-vm.lisp say they're not
154   supported on FreeBSD because the floating point state is not saved,
155   but at least as of FreeBSD 4.0, the floating point state *is* saved,
156   so they could be supported after all. Very likely 
157   SIGCONTEXT-FLOATING-POINT-MODES could now be supported, too.
158
159 45:
160   a slew of floating-point-related errors reported by Peter Van Eynde
161   on July 25, 2000:
162         c: Many expressions generate floating infinity on x86/Linux:
163                 (/ 1 0.0)
164                 (/ 1 0.0d0)
165                 (EXPT 10.0 1000)
166                 (EXPT 10.0d0 1000)
167            PVE's regression tests want them to raise errors. sbcl-0.7.0.5
168            on x86/Linux generates the infinities instead. That might or
169            might not be conforming behavior, but it's also inconsistent,
170            which is almost certainly wrong. (Inconsistency: (/ 1 0.0)
171            should give the same result as (/ 1.0 0.0), but instead (/ 1 0.0)
172            generates SINGLE-FLOAT-POSITIVE-INFINITY and (/ 1.0 0.0)
173            signals an error.
174         d: (in section12.erg) various forms a la 
175                 (FLOAT 1 DOUBLE-FLOAT-EPSILON)
176            don't give the right behavior.
177
178 60:
179   The debugger LIST-LOCATIONS command doesn't work properly.
180   (How should it work properly?)
181
182 61:
183   Compiling and loading
184     (DEFUN FAIL (X) (THROW 'FAIL-TAG X))
185     (FAIL 12)
186   then requesting a BACKTRACE at the debugger prompt gives no information
187   about where in the user program the problem occurred.
188
189 64:
190   Using the pretty-printer from the command prompt gives funny
191   results, apparently because the pretty-printer doesn't know
192   about user's command input, including the user's carriage return
193   that the user, and therefore the pretty-printer thinks that
194   the new output block should start indented 2 or more characters
195   rightward of the correct location.
196
197 67:
198   As reported by Winton Davies on a CMU CL mailing list 2000-01-10,
199   and reported for SBCL by Martin Atzmueller 2000-10-20: (TRACE GETHASH)
200   crashes SBCL. In general tracing anything which is used in the 
201   implementation of TRACE is likely to have the same problem.
202
203 78:
204   ANSI says in one place that type declarations can be abbreviated even
205   when the type name is not a symbol, e.g.
206     (DECLAIM ((VECTOR T) *FOOVECTOR*))
207   SBCL doesn't support this. But ANSI says in another place that this
208   isn't allowed. So it's not clear this is a bug after all. (See the
209   e-mail on cmucl-help@cons.org on 2001-01-16 and 2001-01-17 from WHN
210   and Pierre Mai.)
211
212 79:
213   as pointed out by Dan Barlow on sbcl-devel 2000-07-02:
214   The PICK-TEMPORARY-FILE-NAME utility used by LOAD-FOREIGN uses
215   an easily guessable temporary filename in a way which might open
216   applications using LOAD-FOREIGN to hijacking by malicious users
217   on the same machine. Incantations for doing this safely are
218   floating around the net in various "how to write secure programs
219   despite Unix" documents, and it would be good to (1) fix this in 
220   LOAD-FOREIGN, and (2) hunt for any other code which uses temporary
221   files and make it share the same new safe logic.
222
223   (partially alleviated in sbcl-0.7.9.32 by a fix by Matthew Danish to
224    make the temporary filename less easily guessable)
225
226 83:
227   RANDOM-INTEGER-EXTRA-BITS=10 may not be large enough for the RANDOM
228   RNG to be high quality near RANDOM-FIXNUM-MAX; it looks as though
229   the mean of the distribution can be systematically O(0.1%) wrong.
230   Just increasing R-I-E-B is probably not a good solution, since
231   it would decrease efficiency more than is probably necessary. Perhaps
232   using some sort of accept/reject method would be better.
233
234 85:
235   Internally the compiler sometimes evaluates
236     (sb-kernel:type/= (specifier-type '*) (specifier-type t))
237   (I stumbled across this when I added an
238     (assert (not (eq type1 *wild-type*)))
239   in the NAMED :SIMPLE-= type method.) '* isn't really a type, and
240   in a type context should probably be translated to T, and so it's
241   probably wrong to ask whether it's equal to the T type and then (using
242   the EQ type comparison in the NAMED :SIMPLE-= type method) return NIL.
243   (I haven't tried to investigate this bug enough to guess whether
244   there might be any user-level symptoms.)
245
246   In fact, the type system is likely to depend on this inequality not
247   holding... * is not equivalent to T in many cases, such as 
248     (VECTOR *) /= (VECTOR T).
249
250 95:
251   The facility for dumping a running Lisp image to disk gets confused
252   when run without the PURIFY option, and creates an unnecessarily large
253   core file (apparently representing memory usage up to the previous
254   high-water mark). Moreover, when the file is loaded, it confuses the
255   GC, so that thereafter memory usage can never be reduced below that
256   level.
257
258   (As of 0.8.7.3 it's likely that the latter half of this bug is fixed.
259   The interaction between gencgc and the variables used by
260   save-lisp-and-die is still nonoptimal, though, so no respite from
261   big core files yet)
262
263 98:
264   In sbcl-0.6.11.41 (and in all earlier SBCL, and in CMU
265   CL), out-of-line structure slot setters are horribly inefficient
266   whenever the type of the slot is declared, because out-of-line
267   structure slot setters are implemented as closures to save space,
268   so the compiler doesn't compile the type test into code, but
269   instead just saves the type in a lexical closure and interprets it
270   at runtime.
271     To exercise the problem, compile and load
272       (cl:in-package :cl-user)
273       (defstruct foo
274         (bar (error "missing") :type bar))
275       (defvar *foo*)
276       (defun wastrel1 (x)
277         (loop (setf (foo-bar *foo*) x)))
278       (defstruct bar)
279       (defvar *bar* (make-bar))
280       (defvar *foo* (make-foo :bar *bar*))
281       (defvar *setf-foo-bar* #'(setf foo-bar))
282       (defun wastrel2 (x)
283         (loop (funcall *setf-foo-bar* x *foo*)))
284   then run (WASTREL1 *BAR*) or (WASTREL2 *BAR*), hit Ctrl-C, and
285   use BACKTRACE, to see it's spending all essentially all its time
286   in %TYPEP and VALUES-SPECIFIER-TYPE and so forth.
287     One possible solution would be simply to give up on 
288   representing structure slot accessors as functions, and represent
289   them as macroexpansions instead. This can be inconvenient for users,
290   but it's not clear that it's worse than trying to help by expanding
291   into a horribly inefficient implementation.
292     As a workaround for the problem, #'(SETF FOO) expressions
293   can be replaced with (EFFICIENT-SETF-FUNCTION FOO), where
294 (defmacro efficient-setf-function (place-function-name)
295   (or #+sbcl (and (sb-int:info :function :accessor-for place-function-name)
296                   ;; a workaround for the problem, encouraging the
297                   ;; inline expansion of the structure accessor, so
298                   ;; that the compiler can optimize its type test
299                   (let ((new-value (gensym "NEW-VALUE-"))
300                         (structure-value (gensym "STRUCTURE-VALUE-")))
301                     `(lambda (,new-value ,structure-value)
302                        (setf (,place-function-name ,structure-value)
303                              ,new-value))))
304       ;; no problem, can just use the ordinary expansion
305       `(function (setf ,place-function-name))))
306
307 100:
308   There's apparently a bug in CEILING optimization which caused 
309   Douglas Crosher to patch the CMU CL version. Martin Atzmueller
310   applied the patches to SBCL and they didn't seem to cause problems
311   (as reported sbcl-devel 2001-05-04). However, since the patches
312   modify nontrivial code which was apparently written incorrectly
313   the first time around, until regression tests are written I'm not 
314   comfortable merging the patches in the CVS version of SBCL.
315
316 108:
317   (TIME (ROOM T)) reports more than 200 Mbytes consed even for
318   a clean, just-started SBCL system. And it seems to be right:
319   (ROOM T) can bring a small computer to its knees for a *long*
320   time trying to GC afterwards. Surely there's some more economical
321   way to implement (ROOM T).
322
323   Daniel Barlow doesn't know what fixed this, but observes that it 
324   doesn't seem to be the case in 0.8.7.3 any more.  Instead, (ROOM T)
325   in a fresh SBCL causes
326
327     debugger invoked on a SB-INT:BUG in thread 5911:
328         failed AVER: "(SAP= CURRENT END)"
329
330   unless a GC has happened beforehand.
331
332 117:
333   When the compiler inline expands functions, it may be that different
334   kinds of return values are generated from different code branches.
335   E.g. an inline expansion of POSITION generates integer results 
336   from one branch, and NIL results from another. When that inline
337   expansion is used in a context where only one of those results
338   is acceptable, e.g.
339     (defun foo (x)
340       (aref *a1* (position x *a2*)))
341   and the compiler can't prove that the unacceptable branch is 
342   never taken, then bogus type mismatch warnings can be generated.
343   If you need to suppress the type mismatch warnings, you can
344   suppress the inline expansion,
345     (defun foo (x)
346       #+sbcl (declare (notinline position)) ; to suppress bug 117 bogowarnings
347       (aref *a1* (position x *a2*)))
348   or, sometimes, suppress them by declaring the result to be of an
349   appropriate type,
350     (defun foo (x)
351       (aref *a1* (the integer (position x *a2*))))
352
353   This is not a new compiler problem in 0.7.0, but the new compiler
354   transforms for FIND, POSITION, FIND-IF, and POSITION-IF make it 
355   more conspicuous. If you don't need performance from these functions,
356   and the bogus warnings are a nuisance for you, you can return to
357   your pre-0.7.0 state of grace with
358     #+sbcl (declaim (notinline find position find-if position-if)) ; bug 117..
359
360   (see also bug 279)
361
362 118:
363    as reported by Eric Marsden on cmucl-imp@cons.org 2001-08-14:
364      (= (FLOAT 1 DOUBLE-FLOAT-EPSILON)
365         (+ (FLOAT 1 DOUBLE-FLOAT-EPSILON) DOUBLE-FLOAT-EPSILON)) => T
366    when of course it should be NIL. (He says it only fails for X86,
367    not SPARC; dunno about Alpha.)
368
369    Also, "the same problem exists for LONG-FLOAT-EPSILON,
370    DOUBLE-FLOAT-NEGATIVE-EPSILON, LONG-FLOAT-NEGATIVE-EPSILON (though
371    for the -negative- the + is replaced by a - in the test)."
372
373    Raymond Toy comments that this is tricky on the X86 since its FPU
374    uses 80-bit precision internally.
375
376    Bruno Haible comments:
377      The values are those that are expected for an IEEE double-float
378      arithmetic. The problem appears to be that the rounding is not
379      IEEE on x86 compliant: namely, values are first rounded to 64
380      bits mantissa precision, then only to 53 bits mantissa
381      precision. This gives different results than rounding to 53 bits
382      mantissa precision in a single step.
383
384      The quick "fix", to permanently change the FPU control word from
385      0x037f to 0x027f, will give problems with the fdlibm code that is
386      used for computing transcendental functions like sinh() etc.
387    so maybe we need to change the FPU control word to that for Lisp
388    code, and adjust it to the safe 0x037f for calls to C?
389
390 124:
391    As of version 0.pre7.14, SBCL's implementation of MACROLET makes
392    the entire lexical environment at the point of MACROLET available
393    in the bodies of the macroexpander functions. In particular, it
394    allows the function bodies (which run at compile time) to try to
395    access lexical variables (which are only defined at runtime).
396    It doesn't even issue a warning, which is bad.
397
398    The SBCL behavior arguably conforms to the ANSI spec (since the
399    spec says that the behavior is undefined, ergo anything conforms).
400    However, it would be better to issue a compile-time error.
401    Unfortunately I (WHN) don't see any simple way to detect this
402    condition in order to issue such an error, so for the meantime
403    SBCL just does this weird broken "conforming" thing.
404
405    The ANSI standard says, in the definition of the special operator
406    MACROLET,
407        The macro-expansion functions defined by MACROLET are defined
408        in the lexical environment in which the MACROLET form appears.
409        Declarations and MACROLET and SYMBOL-MACROLET definitions affect
410        the local macro definitions in a MACROLET, but the consequences
411        are undefined if the local macro definitions reference any
412        local variable or function bindings that are visible in that
413        lexical environment.
414    Then it seems to contradict itself by giving the example
415         (defun foo (x flag)
416            (macrolet ((fudge (z)
417                          ;The parameters x and flag are not accessible
418                          ; at this point; a reference to flag would be to
419                          ; the global variable of that name.
420                          ` (if flag (* ,z ,z) ,z)))
421             ;The parameters x and flag are accessible here.
422              (+ x
423                 (fudge x)
424                 (fudge (+ x 1)))))
425    The comment "a reference to flag would be to the global variable
426    of the same name" sounds like good behavior for the system to have.
427    but actual specification quoted above says that the actual behavior
428    is undefined.
429
430    (Since 0.7.8.23 macroexpanders are defined in a restricted version
431    of the lexical environment, containing no lexical variables and
432    functions, which seems to conform to ANSI and CLtL2, but signalling
433    a STYLE-WARNING for references to variables similar to locals might
434    be a good thing.)
435
436 125:
437    (as reported by Gabe Garza on cmucl-help 2001-09-21)
438         (defvar *tmp* 3)
439         (defun test-pred (x y)
440           (eq x y))
441         (defun test-case ()
442           (let* ((x *tmp*)
443                  (func (lambda () x)))
444             (print (eq func func))
445             (print (test-pred func func))
446             (delete func (list func))))
447    Now calling (TEST-CASE) gives output
448      NIL
449      NIL
450      (#<FUNCTION {500A9EF9}>)
451    Evidently Python thinks of the lambda as a code transformation so
452    much that it forgets that it's also an object.
453
454 135:
455   Ideally, uninterning a symbol would allow it, and its associated
456   FDEFINITION and PROCLAIM data, to be reclaimed by the GC. However,
457   at least as of sbcl-0.7.0, this isn't the case. Information about
458   FDEFINITIONs and PROCLAIMed properties is stored in globaldb.lisp
459   essentially in ordinary (non-weak) hash tables keyed by symbols.
460   Thus, once a system has an entry in this system, it tends to live
461   forever, even when it is uninterned and all other references to it
462   are lost.
463
464 141: "pretty printing and backquote"
465   a.
466     * '``(FOO ,@',@S)
467     ``(FOO SB-IMPL::BACKQ-COMMA-AT S)
468
469   c. (reported by Paul F. Dietz)
470      * '`(lambda ,x)
471      `(LAMBDA (SB-IMPL::BACKQ-COMMA X))
472
473 143:
474   (reported by Jesse Bouwman 2001-10-24 through the unfortunately
475   prominent SourceForge web/db bug tracking system, which is 
476   unfortunately not a reliable way to get a timely response from
477   the SBCL maintainers)
478       In the course of trying to build a test case for an 
479     application error, I encountered this behavior: 
480       If you start up sbcl, and then lay on CTRL-C for a 
481     minute or two, the lisp process will eventually say: 
482          %PRIMITIVE HALT called; the party is over. 
483     and throw you into the monitor. If I start up lisp, 
484     attach to the process with strace, and then do the same 
485     (abusive) thing, I get instead: 
486          access failure in heap page not marked as write-protected 
487     and the monitor again. I don't know enough to have the 
488     faintest idea of what is going on here. 
489       This is with sbcl 6.12, uname -a reports: 
490          Linux prep 2.2.19 #4 SMP Tue Apr 24 13:59:52 CDT 2001 i686 unknown 
491   I (WHN) have verified that the same thing occurs on sbcl-0.pre7.141
492   under OpenBSD 2.9 on my X86 laptop. Do be patient when you try it:
493   it took more than two minutes (but less than five) for me.
494
495 145:
496   a.
497   ANSI allows types `(COMPLEX ,FOO) to use very hairy values for
498   FOO, e.g. (COMPLEX (AND REAL (SATISFIES ODDP))). The old CMU CL
499   COMPLEX implementation didn't deal with this, and hasn't been
500   upgraded to do so. (This doesn't seem to be a high priority
501   conformance problem, since seems hard to construct useful code
502   where it matters.)
503
504   b. (fixed in 0.8.3.43)
505
506 146:
507   Floating point errors are reported poorly. E.g. on x86 OpenBSD
508   with sbcl-0.7.1, 
509         * (expt 2.0 12777)
510         debugger invoked on condition of type SB-KERNEL:FLOATING-POINT-EXCEPTION:
511           An arithmetic error SB-KERNEL:FLOATING-POINT-EXCEPTION was signalled.
512         No traps are enabled? How can this be?
513   It should be possible to be much more specific (overflow, division
514   by zero, etc.) and of course the "How can this be?" should be fixable.
515
516   See also bugs #45.c and #183
517
518 162:
519   (reported by Robert E. Brown 2002-04-16) 
520   When a function is called with too few arguments, causing the
521   debugger to be entered, the uninitialized slots in the bad call frame 
522   seem to cause GCish problems, being interpreted as tagged data even
523   though they're not. In particular, executing ROOM in the
524   debugger at that point causes AVER failures:
525     * (machine-type)
526     "X86"
527     * (lisp-implementation-version)
528     "0.7.2.12"
529     * (typep 10)
530     ...
531     0] (room)
532     ...
533     failed AVER: "(SAP= CURRENT END)"
534   (Christophe Rhodes reports that this doesn't occur on the SPARC, which
535   isn't too surprising since there are many differences in stack
536   implementation and GC conservatism between the X86 and other ports.)
537
538   This is probably the same bug as 216
539
540 167:
541   In sbcl-0.7.3.11, compiling the (illegal) code 
542     (in-package :cl-user)
543     (defmethod prove ((uustk uustk))
544       (zap ((frob () nil))
545         (frob)))
546   gives the (not terribly clear) error message
547     ; caught ERROR:
548     ;   (during macroexpansion of (DEFMETHOD PROVE ...))
549     ; can't get template for (FROB NIL NIL)
550   The problem seems to be that the code walker used by the DEFMETHOD
551   macro is unhappy with the illegal syntax in the method body, and
552   is giving an unclear error message.
553
554 173:
555   The compiler sometimes tries to constant-fold expressions before
556   it checks to see whether they can be reached. This can lead to 
557   bogus warnings about errors in the constant folding, e.g. in code
558   like 
559     (WHEN X
560       (WRITE-STRING (> X 0) "+" "0"))
561   compiled in a context where the compiler can prove that X is NIL,
562   and the compiler complains that (> X 0) causes a type error because
563   NIL isn't a valid argument to #'>. Until sbcl-0.7.4.10 or so this
564   caused a full WARNING, which made the bug really annoying because then 
565   COMPILE and COMPILE-FILE returned FAILURE-P=T for perfectly legal
566   code. Since then the warning has been downgraded to STYLE-WARNING, 
567   so it's still a bug but at least it's a little less annoying.
568
569 183: "IEEE floating point issues"
570   Even where floating point handling is being dealt with relatively
571   well (as of sbcl-0.7.5, on sparc/sunos and alpha; see bug #146), the
572   accrued-exceptions and current-exceptions part of the fp control
573   word don't seem to bear much relation to reality. E.g. on
574   SPARC/SunOS:
575   * (/ 1.0 0.0)
576
577   debugger invoked on condition of type DIVISION-BY-ZERO:
578     arithmetic error DIVISION-BY-ZERO signalled
579   0] (sb-vm::get-floating-point-modes)
580
581   (:TRAPS (:OVERFLOW :INVALID :DIVIDE-BY-ZERO)
582           :ROUNDING-MODE :NEAREST
583           :CURRENT-EXCEPTIONS NIL
584           :ACCRUED-EXCEPTIONS (:INEXACT)
585           :FAST-MODE NIL)
586   0] abort
587   * (sb-vm::get-floating-point-modes)
588   (:TRAPS (:OVERFLOW :INVALID :DIVIDE-BY-ZERO)
589           :ROUNDING-MODE :NEAREST
590           :CURRENT-EXCEPTIONS (:INEXACT)
591           :ACCRUED-EXCEPTIONS (:INEXACT)
592           :FAST-MODE NIL)
593
594 188: "compiler performance fiasco involving type inference and UNION-TYPE"
595     (time (compile
596            nil
597            '(lambda ()
598              (declare (optimize (safety 3)))
599              (declare (optimize (compilation-speed 2)))
600              (declare (optimize (speed 1) (debug 1) (space 1)))
601              (let ((start 4))
602                (declare (type (integer 0) start))
603                (print (incf start 22))
604                (print (incf start 26))
605                (print (incf start 28)))
606              (let ((start 6))
607                (declare (type (integer 0) start))
608                (print (incf start 22))
609                (print (incf start 26)))
610              (let ((start 10))
611                (declare (type (integer 0) start))
612                (print (incf start 22))
613                (print (incf start 26))))))
614
615   This example could be solved with clever enough constraint
616   propagation or with SSA, but consider
617
618     (let ((x 0))
619       (loop (incf x 2)))
620
621   The careful type of X is {2k} :-(. Is it really important to be
622   able to work with unions of many intervals?
623
624 191: "Miscellaneous PCL deficiencies"
625   (reported by Alexey Dejneka sbcl-devel 2002-08-04)
626   a. DEFCLASS does not inform the compiler about generated
627      functions. Compiling a file with
628        (DEFCLASS A-CLASS ()
629          ((A-CLASS-X)))
630        (DEFUN A-CLASS-X (A)
631          (WITH-SLOTS (A-CLASS-X) A
632            A-CLASS-X))
633      results in a STYLE-WARNING:
634        undefined-function 
635          SB-SLOT-ACCESSOR-NAME::|COMMON-LISP-USER A-CLASS-X slot READER|
636
637      APD's fix for this was checked in to sbcl-0.7.6.20, but Pierre
638      Mai points out that the declamation of functions is in fact
639      incorrect in some cases (most notably for structure
640      classes).  This means that at present erroneous attempts to use
641      WITH-SLOTS and the like on classes with metaclass STRUCTURE-CLASS
642      won't get the corresponding STYLE-WARNING.
643   c. (fixed in 0.8.4.23)
644
645 201: "Incautious type inference from compound types"
646   a. (reported by APD sbcl-devel 2002-09-17)
647     (DEFUN FOO (X)
648       (LET ((Y (CAR (THE (CONS INTEGER *) X))))
649         (SETF (CAR X) NIL)
650         (FORMAT NIL "~S IS ~S, Y = ~S"
651                 (CAR X)
652                 (TYPECASE (CAR X)
653                   (INTEGER 'INTEGER)
654                   (T '(NOT INTEGER)))
655                 Y)))
656
657     (FOO ' (1 . 2)) => "NIL IS INTEGER, Y = 1"
658
659   b.
660     * (defun foo (x)
661         (declare (type (array * (4 4)) x))
662         (let ((y x))
663           (setq x (make-array '(4 4)))
664           (adjust-array y '(3 5))
665           (= (array-dimension y 0) (eval `(array-dimension ,y 0)))))
666     FOO
667     * (foo (make-array '(4 4) :adjustable t))
668     NIL
669
670 205: "environment issues in cross compiler"
671   (These bugs have no impact on user code, but should be fixed or
672   documented.)
673   a. Macroexpanders introduced with MACROLET are defined in the null
674      lexical environment.
675   b. The body of (EVAL-WHEN (:COMPILE-TOPLEVEL) ...) is evaluated in
676      the null lexical environment.
677   c. The cross-compiler cannot inline functions defined in a non-null
678      lexical environment.
679
680 206: ":SB-FLUID feature broken"
681   (reported by Antonio Martinez-Shotton sbcl-devel 2002-10-07)
682   Enabling :SB-FLUID in the target-features list in sbcl-0.7.8 breaks
683   the build.
684
685 207: "poorly distributed SXHASH results for compound data"
686   SBCL's SXHASH could probably try a little harder. ANSI: "the
687   intent is that an implementation should make a good-faith
688   effort to produce hash-codes that are well distributed
689   within the range of non-negative fixnums". But
690         (let ((hits (make-hash-table)))
691           (dotimes (i 16)
692             (dotimes (j 16)
693               (let* ((ij (cons i j))
694                      (newlist (push ij (gethash (sxhash ij) hits))))
695                 (when (cdr newlist)
696                   (format t "~&collision: ~S~%" newlist))))))
697   reports lots of collisions in sbcl-0.7.8. A stronger MIX function
698   would be an obvious way of fix. Maybe it would be acceptably efficient
699   to redo MIX using a lookup into a 256-entry s-box containing
700   29-bit pseudorandom numbers?
701
702 211: "keywords processing"
703   a. :ALLOW-OTHER-KEYS T should allow a function to receive an odd
704      number of keyword arguments.
705   e. Compiling
706
707       (flet ((foo (&key y) (list y)))
708         (list (foo :y 1 :y 2)))
709
710      issues confusing message
711
712        ; in: LAMBDA NIL
713        ;     (FOO :Y 1 :Y 2)
714        ;
715        ; caught STYLE-WARNING:
716        ;   The variable #:G15 is defined but never used.
717
718 212: "Sequence functions and circular arguments"
719   COERCE, MERGE and CONCATENATE go into an infinite loop when given
720   circular arguments; it would be good for the user if they could be
721   given an error instead (ANSI 17.1.1 allows this behaviour on the part
722   of the implementation, as conforming code cannot give non-proper
723   sequences to these functions.  MAP also has this problem (and
724   solution), though arguably the convenience of being able to do
725     (MAP 'LIST '+ FOO '#1=(1 . #1#))
726   might be classed as more important (though signalling an error when
727   all of the arguments are circular is probably desireable).
728
729 213: "Sequence functions and type checking"
730   b. MAP, when given a type argument that is SUBTYPEP LIST, does not
731      check that it will return a sequence of the given type.  Fixing
732      it along the same lines as the others (cf. work done around
733      sbcl-0.7.8.45) is possible, but doing so efficiently didn't look
734      entirely straightforward.
735   c. All of these functions will silently accept a type of the form
736        (CONS INTEGER *)
737      whether or not the return value is of this type.  This is
738      probably permitted by ANSI (see "Exceptional Situations" under
739      ANSI MAKE-SEQUENCE), but the DERIVE-TYPE mechanism does not
740      know about this escape clause, so code of the form
741        (INTEGERP (CAR (MAKE-SEQUENCE '(CONS INTEGER *) 2)))
742      can erroneously return T.
743
744 215: ":TEST-NOT handling by functions"
745   a. FIND and POSITION currently signal errors when given non-NIL for
746      both their :TEST and (deprecated) :TEST-NOT arguments, but by
747      ANSI 17.2 "the consequences are unspecified", which by ANSI 1.4.2
748      means that the effect is "unpredictable but harmless".  It's not
749      clear what that actually means; it may preclude conforming
750      implementations from signalling errors.
751   b. COUNT, REMOVE and the like give priority to a :TEST-NOT argument
752      when conflict occurs.  As a quality of implementation issue, it
753      might be preferable to treat :TEST and :TEST-NOT as being in some
754      sense the same &KEY, and effectively take the first test function in
755      the argument list.
756   c. Again, a quality of implementation issue: it would be good to issue a
757      STYLE-WARNING at compile-time for calls with :TEST-NOT, and a
758      WARNING for calls with both :TEST and :TEST-NOT; possibly this
759      latter should be WARNed about at execute-time too.
760
761 216: "debugger confused by frames with invalid number of arguments"
762   In sbcl-0.7.8.51, executing e.g. (VECTOR-PUSH-EXTEND T), BACKTRACE, Q
763   leaves the system confused, enough so that (QUIT) no longer works.
764   It's as though the process of working with the uninitialized slot in
765   the bad VECTOR-PUSH-EXTEND frame causes GC problems, though that may
766   not be the actual problem. (CMU CL 18c doesn't have problems with this.)
767
768   This is probably the same bug as 162
769
770 217: "Bad type operations with FUNCTION types"
771   In sbcl.0.7.7:
772
773     * (values-type-union (specifier-type '(function (base-char)))
774                          (specifier-type '(function (integer))))
775
776     #<FUN-TYPE (FUNCTION (BASE-CHAR) *)>
777
778   It causes insertion of wrong type assertions into generated
779   code. E.g.
780
781     (defun foo (x s)
782       (let ((f (etypecase x
783                  (character #'write-char)
784                  (integer #'write-byte))))
785         (funcall f x s)
786         (etypecase x
787           (character (write-char x s))
788           (integer (write-byte x s)))))
789
790    Then (FOO #\1 *STANDARD-OUTPUT*) signals type error.
791
792   (In 0.7.9.1 the result type is (FUNCTION * *), so Python does not
793   produce invalid code, but type checking is not accurate.)
794
795 233: bugs in constraint propagation
796   b.
797   (declaim (optimize (speed 2) (safety 3)))
798   (defun foo (x y)
799     (if (typep (prog1 x (setq x y)) 'double-float)
800         (+ x 1d0)
801         (+ x 2)))
802   (foo 1d0 5) => segmentation violation
803
804 235: "type system and inline expansion"
805   a.
806   (declaim (ftype (function (cons) number) acc))
807   (declaim (inline acc))
808   (defun acc (c)
809     (the number (car c)))
810
811   (defun foo (x y)
812     (values (locally (declare (optimize (safety 0)))
813               (acc x))
814             (locally (declare (optimize (safety 3)))
815               (acc y))))
816
817   (foo '(nil) '(t)) => NIL, T.
818
819 237: "Environment arguments to type functions"
820   a. Functions SUBTYPEP, TYPEP, UPGRADED-ARRAY-ELEMENT-TYPE, and 
821      UPGRADED-COMPLEX-PART-TYPE now have an optional environment
822      argument, but they ignore it completely.  This is almost 
823      certainly not correct.
824   b. Also, the compiler's optimizers for TYPEP have not been informed
825      about the new argument; consequently, they will not transform
826      calls of the form (TYPEP 1 'INTEGER NIL), even though this is
827      just as optimizeable as (TYPEP 1 'INTEGER).
828
829 238: "REPL compiler overenthusiasm for CLOS code"
830   From the REPL,
831     * (defclass foo () ())
832     * (defmethod bar ((x foo) (foo foo)) (call-next-method))
833   causes approximately 100 lines of code deletion notes.  Some
834   discussion on this issue happened under the title 'Three "interesting"
835   bugs in PCL', resulting in a fix for this oververbosity from the
836   compiler proper; however, the problem persists in the interactor
837   because the notion of original source is not preserved: for the
838   compiler, the original source of the above expression is (DEFMETHOD
839   BAR ((X FOO) (FOO FOO)) (CALL-NEXT-METHOD)), while by the time the
840   compiler gets its hands on the code needing compilation from the REPL,
841   it has been macroexpanded several times.
842
843   A symptom of the same underlying problem, reported by Tony Martinez:
844     * (handler-case
845         (with-input-from-string (*query-io* "    no")
846           (yes-or-no-p))
847       (simple-type-error () 'error))
848     ; in: LAMBDA NIL
849     ;     (SB-KERNEL:FLOAT-WAIT)
850     ; 
851     ; note: deleting unreachable code
852     ; compilation unit finished
853     ;   printed 1 note
854
855 242: "WRITE-SEQUENCE suboptimality"
856   (observed from clx performance)
857   In sbcl-0.7.13, WRITE-SEQUENCE of a sequence of type 
858   (SIMPLE-ARRAY (UNSIGNED-BYTE 8) (*)) on a stream with element-type
859   (UNSIGNED-BYTE 8) will write to the stream one byte at a time,
860   rather than writing the sequence in one go, leading to severe
861   performance degradation.
862
863 243: "STYLE-WARNING overenthusiasm for unused variables"
864   (observed from clx compilation)
865   In sbcl-0.7.14, in the presence of the macros
866     (DEFMACRO FOO (X) `(BAR ,X))
867     (DEFMACRO BAR (X) (DECLARE (IGNORABLE X)) 'NIL)
868   somewhat surprising style warnings are emitted for
869     (COMPILE NIL '(LAMBDA (Y) (FOO Y))):
870   ; in: LAMBDA (Y)
871   ;     (LAMBDA (Y) (FOO Y))
872   ; 
873   ; caught STYLE-WARNING:
874   ;   The variable Y is defined but never used.
875
876 245: bugs in disassembler
877   b. On X86 operand size prefix is not recognized.
878
879 251:
880   (defun foo (&key (a :x))
881     (declare (fixnum a))
882     a)
883
884   does not cause a warning. (BTW: old SBCL issued a warning, but for a
885   function, which was never called!)
886
887 256:
888   Compiler does not emit warnings for
889
890   a. (lambda () (svref (make-array 8 :adjustable t) 1))
891
892   b. (lambda (x)
893        (list (let ((y (the real x)))
894                (unless (floatp y) (error ""))
895                y)
896              (integer-length x)))
897
898   c. (lambda (x)
899        (declare (optimize (debug 0)))
900        (declare (type vector x))
901        (list (fill-pointer x)
902              (svref x 1)))
903
904 257:
905   Complex array type does not have corresponding type specifier.
906
907   This is a problem because the compiler emits optimization notes when
908   you use a non-simple array, and without a type specifier for hairy
909   array types, there's no good way to tell it you're doing it
910   intentionally so that it should shut up and just compile the code.
911
912   Another problem is confusing error message "asserted type ARRAY
913   conflicts with derived type (VALUES SIMPLE-VECTOR &OPTIONAL)" during
914   compiling (LAMBDA (V) (VALUES (SVREF V 0) (VECTOR-POP V))).
915
916   The last problem is that when type assertions are converted to type
917   checks, types are represented with type specifiers, so we could lose
918   complex attribute. (Now this is probably not important, because
919   currently checks for complex arrays seem to be performed by
920   callees.)
921
922 259:
923   (compile nil '(lambda () (aref (make-array 0) 0))) compiles without
924   warning.  Analogous cases with the index and length being equal and
925   greater than 0 are warned for; the problem here seems to be that the
926   type required for an array reference of this type is (INTEGER 0 (0))
927   which is canonicalized to NIL.
928
929 260:
930   a.
931   (let* ((s (gensym))
932          (t1 (specifier-type s)))
933     (eval `(defstruct ,s))
934     (type= t1 (specifier-type s)))
935   => NIL, NIL
936
937   (fixed in 0.8.1.24)
938
939   b. The same for CSUBTYPEP.
940
941 262: "yet another bug in inline expansion of local functions"
942   Compiler fails on
943
944     (defun foo (x y)
945       (declare (integer x y))
946       (+ (block nil
947             (flet ((xyz (u)
948                      (declare (integer u))
949                      (if (> (1+ (the unsigned-byte u)) 0)
950                          (+ 1 u)
951                          (return (+ 38 (cos (/ u 78)))))))
952               (declare (inline xyz))
953               (return-from foo
954                 (* (funcall (eval #'xyz) x)
955                    (if (> x 30)
956                        (funcall (if (> x 5) #'xyz #'identity)
957                                 (+ x 13))
958                        38)))))
959          (sin (* x y))))
960
961   Urgh... It's time to write IR1-copier.
962
963 266:
964   David Lichteblau provided (sbcl-devel 2003-06-01) a patch to fix
965   behaviour of streams with element-type (SIGNED-BYTE 8).  The patch
966   looks reasonable, if not obviously correct; however, it caused the
967   PPC/Linux port to segfault during warm-init while loading
968   src/pcl/std-class.fasl.  A workaround patch was made, but it would
969   be nice to understand why the first patch caused problems, and to
970   fix the cause if possible.
971
972 268: "wrong free declaration scope"
973   The following code must signal type error:
974
975     (locally (declare (optimize (safety 3)))
976       (flet ((foo (x &optional (y (car x)))
977                (declare (optimize (safety 0)))
978                (list x y)))
979         (funcall (eval #'foo) 1)))
980
981 269:
982   SCALE-FLOAT should accept any integer for its second argument.
983
984 270:
985   In the following function constraint propagator optimizes nothing:
986
987     (defun foo (x)
988       (declare (integer x))
989       (declare (optimize speed))
990       (typecase x
991         (fixnum "hala")
992         (fixnum "buba")
993         (bignum "hip")
994         (t "zuz")))
995
996 273:
997   Compilation of the following two forms causes "X is unbound" error:
998
999     (symbol-macrolet ((x pi))
1000       (macrolet ((foo (y) (+ x y)))
1001         (declaim (inline bar))
1002         (defun bar (z)
1003           (* z (foo 4)))))
1004     (defun quux (z)
1005       (bar z))
1006
1007   (See (COERCE (CDR X) 'FUNCTION) in IR1-CONVERT-INLINE-LAMBDA.)
1008
1009 274:
1010   CLHS says that type declaration of a symbol macro should not affect
1011   its expansion, but in SBCL it does. (If you like magic and want to
1012   fix it, don't forget to change all uses of MACROEXPAND to
1013   MACROEXPAND*.)
1014
1015 275:
1016   The following code (taken from CLOCC) takes a lot of time to compile:
1017
1018     (defun foo (n)
1019       (declare (type (integer 0 #.large-constant) n))
1020       (expt 1/10 n))
1021
1022   (fixed in 0.8.2.51, but a test case would be good)
1023
1024 276:
1025     (defmethod fee ((x fixnum))
1026       (setq x (/ x 2))
1027       x)
1028     (fee 1) => type error
1029
1030   (taken from CLOCC)
1031
1032 278:
1033   a.
1034     (defun foo ()
1035       (declare (optimize speed))
1036       (loop for i of-type (integer 0) from 0 by 2 below 10
1037             collect i))
1038
1039   uses generic arithmetic.
1040
1041   b. (fixed in 0.8.3.6)
1042
1043 279: type propagation error -- correctly inferred type goes astray?
1044   In sbcl-0.8.3 and sbcl-0.8.1.47, the warning
1045        The binding of ABS-FOO is a (VALUES (INTEGER 0 0)
1046        &OPTIONAL), not a (INTEGER 1 536870911)
1047   is emitted when compiling this file:
1048     (declaim (ftype (function ((integer 0 #.most-positive-fixnum))
1049                               (integer #.most-negative-fixnum 0))
1050                     foo))
1051     (defun foo (x)
1052       (- x))
1053     (defun bar (x)
1054       (let* (;; Uncomment this for a type mismatch warning indicating 
1055              ;; that the type of (FOO X) is correctly understood.
1056              #+nil (fs-foo (float-sign (foo x)))
1057                    ;; Uncomment this for a type mismatch warning 
1058                    ;; indicating that the type of (ABS (FOO X)) is
1059                    ;; correctly understood.
1060              #+nil (fs-abs-foo (float-sign (abs (foo x))))
1061              ;; something wrong with this one though
1062              (abs-foo (abs (foo x))))
1063         (declare (type (integer 1 100) abs-foo))
1064         (print abs-foo)))
1065
1066  (see also bug 117)
1067
1068 281: COMPUTE-EFFECTIVE-METHOD error signalling.
1069   (slightly obscured by a non-0 default value for
1070    SB-PCL::*MAX-EMF-PRECOMPUTE-METHODS*)
1071   It would be natural for COMPUTE-EFFECTIVE-METHOD to signal errors
1072   when it finds a method with invalid qualifiers.  However, it
1073   shouldn't signal errors when any such methods are not applicable to
1074   the particular call being evaluated, and certainly it shouldn't when
1075   simply precomputing effective methods that may never be called.
1076   (setf sb-pcl::*max-emf-precompute-methods* 0)
1077   (defgeneric foo (x)
1078     (:method-combination +)
1079     (:method ((x symbol)) 1)
1080     (:method + ((x number)) x))
1081   (foo 1) -> ERROR, but should simply return 1
1082
1083   The issue seems to be that construction of a discriminating function
1084   calls COMPUTE-EFFECTIVE-METHOD with methods that are not all applicable.
1085
1086 283: Thread safety: libc functions
1087   There are places that we call unsafe-for-threading libc functions
1088   that we should find alternatives for, or put locks around.  Known or
1089   strongly suspected problems, as of 0.8.3.10: please update this
1090   bug instead of creating new ones
1091
1092     localtime() - called for timezone calculations in code/time.lisp
1093
1094 284: Thread safety: special variables
1095   There are lots of special variables in SBCL, and I feel sure that at
1096   least some of them are indicative of potentially thread-unsafe 
1097   parts of the system.  See doc/internals/notes/threading-specials
1098
1099 286: "recursive known functions"
1100   Self-call recognition conflicts with known function
1101   recognition. Currently cross compiler and target COMPILE do not
1102   recognize recursion, and in target compiler it can be disabled. We
1103   can always disable it for known functions with RECURSIVE attribute,
1104   but there remains a possibility of a function with a
1105   (tail)-recursive simplification pass and transforms/VOPs for base
1106   cases.
1107
1108 287: PPC/Linux miscompilation or corruption in first GC
1109   When the runtime is compiled with -O3 on certain PPC/Linux machines, a
1110   segmentation fault is reported at the point of first triggered GC,
1111   during the compilation of DEFSTRUCT WRAPPER.  As a temporary workaround,
1112   the runtime is no longer compiled with -O3 on PPC/Linux, but it is likely
1113   that this merely obscures, not solves, the underlying problem; as and when
1114   underlying problems are fixed, it would be worth trying again to provoke
1115   this problem.
1116
1117 288: fundamental cross-compilation issues (from old UGLINESS file)
1118   Using host floating point numbers to represent target floating point
1119   numbers, or host characters to represent target characters, is
1120   theoretically shaky. (The characters are OK as long as the characters
1121   are in the ANSI-guaranteed character set, though, so they aren't a
1122   real problem as long as the sources don't need anything but that;
1123   the floats are a real problem.)
1124
1125 289: "type checking and source-transforms"
1126   a.
1127     (block nil (let () (funcall #'+ (eval 'nil) (eval '1) (return :good))))
1128   signals type error.
1129
1130   Our policy is to check argument types at the moment of a call. It
1131   disagrees with ANSI, which says that type assertions are put
1132   immediately onto argument expressions, but is easier to implement in
1133   IR1 and is more compatible to type inference, inline expansion,
1134   etc. IR1-transforms automatically keep this policy, but source
1135   transforms for associative functions (such as +), being applied
1136   during IR1-convertion, do not. It may be tolerable for direct calls
1137   (+ x y z), but for (FUNCALL #'+ x y z) it is non-conformant.
1138
1139   b. Another aspect of this problem is efficiency. [x y + z +]
1140   requires less registers than [x y z + +]. This transformation is
1141   currently performed with source transforms, but it would be good to
1142   also perform it in IR1 optimization phase.
1143
1144 290: Alpha floating point and denormalized traps
1145   In SBCL 0.8.3.6x on the alpha, we work around what appears to be a
1146   hardware or kernel deficiency: the status of the enable/disable
1147   denormalized-float traps bit seems to be ambiguous; by the time we
1148   get to os_restore_fp_control after a trap, denormalized traps seem
1149   to be enabled.  Since we don't want a trap every time someone uses a
1150   denormalized float, in general, we mask out that bit when we restore
1151   the control word; however, this clobbers any change the user might
1152   have made.
1153
1154 296:
1155   (reported by Adam Warner, sbcl-devel 2003-09-23)
1156
1157   The --load toplevel argument does not perform any sanitization of its
1158   argument.  As a result, files with Lisp pathname pattern characters
1159   (#\* or #\?, for instance) or quotation marks can cause the system
1160   to perform arbitrary behaviour.
1161
1162 297:
1163   LOOP with non-constant arithmetic step clauses suffers from overzealous
1164   type constraint: code of the form 
1165     (loop for d of-type double-float from 0d0 to 10d0 by x collect d)
1166   compiles to a type restriction on X of (AND DOUBLE-FLOAT (REAL
1167   (0))).  However, an integral value of X should be legal, because
1168   successive adds of integers to double-floats produces double-floats,
1169   so none of the type restrictions in the code is violated.
1170
1171 300: (reported by Peter Graves) Function PEEK-CHAR checks PEEK-TYPE
1172   argument type only after having read a character. This is caused
1173   with EXPLICIT-CHECK attribute in DEFKNOWN. The similar problem
1174   exists with =, /=, <, >, <=, >=. They were fixed, but it is probably
1175   less error prone to have EXPLICIT-CHECK be a local declaration,
1176   being put into the definition, instead of an attribute being kept in
1177   a separate file; maybe also put it into SB-EXT?
1178
1179 301: ARRAY-SIMPLE-=-TYPE-METHOD breaks on corner cases which can arise
1180      in NOTE-ASSUMED-TYPES
1181   In sbcl-0.8.7.32, compiling the file
1182         (defun foo (x y)
1183           (declare (type integer x))
1184           (declare (type (vector (or hash-table bit)) y))
1185           (bletch 2 y))
1186         (defun bar (x y)
1187           (declare (type integer x))
1188           (declare (type (simple-array base (2)) y))
1189           (bletch 1 y))
1190   gives the error
1191     failed AVER: "(NOT (AND (NOT EQUALP) CERTAINP))"
1192
1193 302: Undefined type messes up DATA-VECTOR-REF expansion.
1194   Compiling this file
1195     (defun dis (s ei x y)
1196       (declare (type (simple-array function (2)) s) (type ei ei))
1197       (funcall (aref s ei) x y))
1198   on sbcl-0.8.7.36/X86/Linux causes a BUG to be signalled:
1199     full call to SB-KERNEL:DATA-VECTOR-REF
1200
1201 303: "nonlinear LVARs" (aka MISC.293)
1202     (defun buu (x)
1203       (multiple-value-call #'list
1204         (block foo
1205           (multiple-value-prog1
1206               (eval '(values :a :b :c))
1207             (catch 'bar
1208               (if (> x 0)
1209                   (return-from foo
1210                     (eval `(if (> ,x 1)
1211                                1
1212                                (throw 'bar (values 3 4)))))))))))
1213
1214   (BUU 1) returns garbage.
1215
1216   The problem is that both EVALs sequentially write to the same LVAR.
1217
1218 305:
1219   (Reported by Dave Roberts.)
1220   Local INLINE/NOTINLINE declaration removes local FTYPE declaration:
1221
1222     (defun quux (x)
1223       (declare (ftype (function () (integer 0 10)) fee)
1224                (inline fee))
1225       (1+ (fee)))
1226
1227   uses generic arithmetic with INLINE and fixnum without.
1228
1229 306: "Imprecise unions of array types"
1230   a.(defun foo (x)
1231       (declare (optimize speed)
1232                (type (or (array cons) (array vector)) x))
1233       (elt (aref x 0) 0))
1234     (foo #((0))) => TYPE-ERROR
1235
1236   relatedly,
1237
1238   b.(subtypep 
1239      'array
1240      `(or
1241        ,@(loop for x across sb-vm:*specialized-array-element-type-properties*
1242                collect `(array ,(sb-vm:saetp-specifier x)))))
1243     => NIL, T (when it should be T, T)
1244
1245 308: "Characters without names"
1246     (reported by Bruno Haible sbcl-devel "character names are missing"
1247     2004-04-19)
1248   (graphic-char-p (code-char 255))
1249   => NIL
1250   (char-name (code-char 255))
1251   => NIL
1252
1253   SBCL is unsure of what to do about characters with codes in the
1254   range 128-255.  Currently they are treated as non-graphic, but don't
1255   have names, which is not compliant with the standard.  Various fixes
1256   are possible, such as
1257   * giving them names such as NON-ASCII-128;
1258   * reducing CHAR-CODE-LIMIT to 127 (almost certainly unpopular);
1259   * making the characters graphic (makes a certain amount of sense);
1260   * biting the bullet and implementing Unicode (probably quite hard).
1261
1262 309: "Dubious values for implementation limits"
1263     (reported by Bruno Haible sbcl-devel "Incorrect value of
1264     multiple-values-limit" 2004-04-19)
1265   (values-list (make-list 1000000)), on x86/linux, signals a stack
1266   exhaustion condition, despite MULTIPLE-VALUES-LIMIT being
1267   significantly larger than 1000000.  There are probably similar
1268   dubious values for CALL-ARGUMENTS-LIMIT (see cmucl-help/cmucl-imp
1269   around the same time regarding a call to LIST on sparc with 1000
1270   arguments) and other implementation limit constants.
1271
1272 311: "Tokeniser not thread-safe"
1273     (see also Robert Marlow sbcl-help "Multi threaded read chucking a
1274     spak" 2004-04-19)
1275   The tokenizer's use of *read-buffer* and *read-buffer-length* causes
1276   spurious errors should two threads attempt to tokenise at the same
1277   time.
1278
1279 314: "LOOP :INITIALLY clauses and scope of initializers"
1280   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1281   test suite, originally by Thomas F. Burdick.
1282     ;; <http://www.lisp.org/HyperSpec/Body/sec_6-1-7-2.html>
1283     ;; According to the HyperSpec 6.1.2.1.4, in for-as-equals-then, var is
1284     ;; initialized to the result of evaluating form1.  6.1.7.2 says that
1285     ;; initially clauses are evaluated in the loop prologue, which precedes all
1286     ;; loop code except for the initial settings provided by with, for, or as.
1287     (loop :for x = 0 :then (1+ x) 
1288           :for y = (1+ x) :then (ash y 1)
1289           :for z :across #(1 3 9 27 81 243) 
1290           :for w = (+ x y z)
1291           :initially (assert (zerop x)) :initially (assert (= 2 w))
1292           :until (>= w 100) :collect w)
1293     Expected: (2 6 15 38)
1294     Got:      ERROR
1295
1296 317: "FORMAT of floating point numbers"
1297   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1298   test suite.
1299     (format nil "~1F" 10) => "0." ; "10." expected
1300     (format nil "~0F" 10) => "0." ; "10." expected
1301     (format nil "~2F" 1234567.1) => "1000000." ; "1234567." expected
1302   it would be nice if whatever fixed this also untangled the two
1303   competing implementations of floating point printing (Steele and
1304   White, and Burger and Dybvig) present in src/code/print.lisp
1305
1306 318: "stack overflow in compiler warning with redefined class"
1307   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1308   test suite.
1309     (setq *print-pretty* nil)
1310     (defstruct foo a)
1311     (setf (find-class 'foo) nil)
1312     (defstruct foo slot-1)
1313   gives 
1314     ...#<SB-KERNEL:STRUCTURE-CLASSOID #<SB-KERNEL:STRUCTURE-CLASSOID #<SB-KERNEL:STRUCTURE-CLASSOID #<SB-KERNEL:STRUCTUREControl stack guard page temporarily disabled: proceed with caution
1315   (it's not really clear what it should give: is (SETF FIND-CLASS)
1316   meant to be enough to delete structure classes from the system?
1317   Giving a stack overflow is definitely suboptimal, though.)
1318
1319 319: "backquote with comma inside array"
1320   reported by Bruno Haible sbcl-devel "various SBCL bugs" from CLISP
1321   test suite.
1322     (read-from-string "`#1A(1 2 ,(+ 2 2) 4)") 
1323   gives
1324     #(1 2 ((SB-IMPL::|,|) + 2 2) 4)
1325   which probably isn't intentional.
1326
1327 323: "REPLACE, BIT-BASH and large strings"
1328   The transform for REPLACE on simple-base-strings uses BIT-BASH, which
1329   at present has an upper limit in size.  Consequently, in sbcl-0.8.10
1330     (defun foo ()
1331       (declare (optimize speed (safety 1)))
1332       (let ((x (make-string 140000000))
1333             (y (make-string 140000000)))
1334         (length (replace x y))))
1335     (foo)
1336   gives 
1337     debugger invoked on a TYPE-ERROR in thread 2412:
1338       The value 1120000000 is not of type (MOD 536870911).
1339   (see also "more and better sequence transforms" sbcl-devel 2004-05-10)
1340
1341 324: "STREAMs and :ELEMENT-TYPE with large bytesize"
1342   In theory, (open foo :element-type '(unsigned-byte <x>)) should work
1343   for all positive integral <x>.  At present, it only works for <x> up
1344   to about 1024 (and similarly for signed-byte), so
1345     (open "/dev/zero" :element-type '(unsigned-byte 1025))
1346   gives an error in sbcl-0.8.10.
1347
1348 325: "CLOSE :ABORT T on supeseding streams"
1349   Closing a stream opened with :IF-EXISTS :SUPERSEDE with :ABORT T leaves no
1350   file on disk, even if one existed before opening.
1351
1352   The illegality of this is not crystal clear, as the ANSI dictionary
1353   entry for CLOSE says that when :ABORT is T superseded files are not
1354   superseded (ie. the original should be restored), whereas the OPEN
1355   entry says about :IF-EXISTS :SUPERSEDE "If possible, the
1356   implementation should not destroy the old file until the new stream
1357   is closed." -- implying that even though undesirable, early deletion
1358   is legal. Restoring the original would none the less be the polite
1359   thing to do.
1360
1361 326: "*PRINT-CIRCLE* crosstalk between streams"
1362   In sbcl-0.8.10.48 it's possible for *PRINT-CIRCLE* references to be
1363   mixed between streams when output operations are intermingled closely
1364   enough (as by doing output on S2 from within (PRINT-OBJECT X S1) in the
1365   test case below), so that e.g. the references #2# appears on a stream
1366   with no preceding #2= on that stream to define it (because the #2= was
1367   sent to another stream).
1368     (cl:in-package :cl-user)
1369     (defstruct foo index)
1370     (defparameter *foo* (make-foo :index 4))
1371     (defstruct bar)
1372     (defparameter *bar* (make-bar))
1373     (defparameter *tangle* (list *foo* *bar* *foo*))
1374     (defmethod print-object ((foo foo) stream)
1375       (let ((index (foo-index foo)))
1376         (format *trace-output*
1377             "~&-$- emitting FOO ~D, ambient *BAR*=~S~%"
1378             index *bar*)
1379         (format stream "[FOO ~D]" index))
1380       foo)
1381     (let ((tsos (make-string-output-stream))
1382           (ssos (make-string-output-stream)))
1383       (let ((*print-circle* t)
1384         (*trace-output* tsos)
1385         (*standard-output* ssos))
1386         (prin1 *tangle* *standard-output*))
1387       (let ((string (get-output-stream-string ssos)))
1388         (unless (string= string "(#1=[FOO 4] #S(BAR) #1#)")
1389           ;; In sbcl-0.8.10.48 STRING was "(#1=[FOO 4] #2# #1#)".:-(
1390           (error "oops: ~S" string))))
1391   It might be straightforward to fix this by turning the
1392   *CIRCULARITY-HASH-TABLE* and *CIRCULARITY-COUNTER* variables into
1393   per-stream slots, but (1) it would probably be sort of messy faking
1394   up the special variable binding semantics using UNWIND-PROTECT and
1395   (2) it might be sort of a pain to test that no other bugs had been
1396   introduced. 
1397
1398 328: "Profiling generic functions", transplanted from #241
1399   (from tonyms on #lisp IRC 2003-02-25)
1400   In sbcl-0.7.12.55, typing
1401     (defclass foo () ((bar :accessor foo-bar)))
1402     (profile foo-bar)
1403     (unintern 'foo-bar)
1404     (defclass foo () ((bar :accessor foo-bar)))
1405   gives the error message
1406     "#:FOO-BAR already names an ordinary function or a macro."
1407
1408   Problem: when a generic function is profiled, it appears as an ordinary
1409   function to PCL. (Remembering the uninterned accessor is OK, as the
1410   redefinition must be able to remove old accessors from their generic
1411   functions.)
1412
1413 329: "Sequential class redefinition"
1414   reported by Bruno Haible:
1415    (defclass reactor () ((max-temp :initform 10000000)))
1416    (defvar *r1* (make-instance 'reactor))
1417    (defvar *r2* (make-instance 'reactor))
1418    (slot-value *r1* 'max-temp)
1419    (slot-value *r2* 'max-temp)
1420    (defclass reactor () ((uptime :initform 0)))
1421    (slot-value *r1* 'uptime)
1422    (defclass reactor () ((uptime :initform 0) (max-temp :initform 10000)))
1423    (slot-value *r1* 'max-temp) ; => 10000
1424    (slot-value *r2* 'max-temp) ; => 10000000 oops...
1425
1426   Possible solution: 
1427    The method effective when the wrapper is obsoleted can be saved
1428      in the wrapper, and then to update the instance just run through
1429      all the old wrappers in order from oldest to newest.
1430
1431 330: "PARSE-NAMESTRING should accept namestrings as the default argument"
1432   (parse-namestring "foo" nil "/") 
1433   debugger invoked on a TYPE-ERROR in thread 3138:
1434     The value "/" is not of type PATHNAME.
1435   According to the PARSE-NAMESTRING dictionary entry the
1436   default-pathname parameter can be any pathname designator.
1437
1438 331: "lazy creation of CLOS classes for user-defined conditions"
1439     (defstruct foo)
1440     (defstruct (bar (:include foo)))
1441     (sb-mop:class-direct-subclasses (find-class 'foo))
1442   returns NIL, rather than a singleton list containing the BAR class.