style-warning on multiple optimize qualities

Bug #310267 reported by Tobias C. Rittweiler on 2008-12-21
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

Quoting CLHS entry for OPTIMIZE

  ``The consequences are unspecified if a quality appears more than once with different values. ''

SBCL just ignores preceding optimize qualities of the same kind. E.g.

  (defun foo1 (x y)
    (declare (optimize (speed 0)))
    (declare (optimize (speed 3)))
    (+ x y))

  (defun foo2 (x y)
    (declare (optimize (speed 3)))
    (declare (optimize (speed 0)))
    (+ x y))

A compiler note is emitted for FOO1, only. I think SBCL should signal a style-warning
in such cases.

[optimize] -

Nikodemus Siivola (nikodemus) wrote :

Even full WARNING may be worth considering.

Changed in sbcl:
importance: Undecided → Low
status: New → Confirmed
Paul Khuong (pvk) wrote :

I'm not sure that's what the spec means. This is in the context of:
  (optimize {quality | (quality value)}*)
so I take it to mean that the consequences are unspecified if a quality appears more than once with different values *in a single OPTIMIZE form*. SBCL doesn't do any checking in that case either, though.

Tobias C. Rittweiler (tcr) wrote :

I think

   (declare (foo x))
   (declare (bar y))

should be regarded being synonymous to

   (declare (foo x) (bar y))

Otherwise frobbing declarations in non-trivial ways would be made considerably
harder when the appearance, and the order is supposed to be taken into account.

Nikodemus Siivola (nikodemus) wrote :

Either way, the stand SBCL takes should be documented -- sanity a bonus...

Also, if all we do is signal a style-warning, we can do it for both cases without a quibble.

Tobias C. Rittweiler (tcr) wrote :

Given the existence of SB-CLTL2:DEFINE-DECLARATION I would actually
prefer to sanction sequential-order processing where the last declaration

Nikodemus Siivola (nikodemus) wrote :

It is not obvious to me that bearing DEFINE-DECLARATION has on this.

Nikodemus Siivola (nikodemus) wrote :

Yoda I am. Sorry, still working on my first coffee.

Changed in sbcl:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers