format directives should be more forgiving to negative arguments

Bug #1439504 reported by James Kalenius
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Won't Fix
Undecided
Unassigned

Bug Description

(format t "~vd" -100 -100) signals an error. This is not the case on other implementations and isn't really supported by the standard, which just says that at least that many columns are printed. In ansi-cl-tests not signalling an error is part of test format.d.29.

The rest of the code as written works fine with negative numbers, so the error call (in format-write-field) just has to be deleted.

Exists in my distro's version (1.2.8) and in github master.

Revision history for this message
James Kalenius (aeshtaer) wrote :
description: updated
Revision history for this message
Stas Boukarev (stassats) wrote :

I don't think anyone would intentionally supply negative arguments, so it's fair to not accept them.

Changed in sbcl:
status: New → Won't Fix
description: updated
Revision history for this message
Christophe Rhodes (csr21-cantab) wrote : Re: [Bug 1439504] Re: format directives should be more forgiving to negative arguments

Stas Boukarev <email address hidden> writes:

> I don't think anyone would intentionally supply negative arguments, so
> it's fair to not accept them.

For what it's worth, I'm not totally convinced by this. If the column
width is being computed programmatically, you could easily end up with a
situation where you subtract one thing from another. If the user is
required never to supply a negative argument, they will have to decorate
their code with (max 0 ...) everywhere -- and they may not detect the
problem until their code is in the field and exposed to the wider set of
inputs that deployment brings.

Christophe

Revision history for this message
Stas Boukarev (stassats) wrote :

That's true for many things, we do not promote (subseq sequence -10) to (subseq sequence 0)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.