FORMAT should not silently accept "~<~@>"

Bug #1153148 reported by Jan Moringen on 2013-03-10
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

What I do:
> (format nil "~<~@>")

What happens:
Returns ""

What I expected to happen:
Signals an error about the format string being invalid.

What I do:
> (compile nil (lambda () (format nil "~<~@>")))

What happens:
Compiles without warnings or errors.

What I expected to happen:
Signals a warning or an error about the format string being invalid.

Clisp and ECL accept this format string sliently.

CCL signals an error for this format string:
$ opt/ccl/lx86cl -e '(format nil "~<~@>")'
> Error:
> Atsign flag not allowed
> "~<~@>"
> ^
> While executing: CCL::DO-SUB-FORMAT, in process listener(1).
> Type :GO to continue, :POP to abort, :R for a list of available restarts.
> If continued: Skip evaluation of (format nil "~<~@>")
> Type :? for other options.
1 >

$ sbcl --version
SBCL 1.1.5
$ uname -a
Linux ferberit 3.5.0-25-generic #38-Ubuntu SMP Mon Feb 18 23:28:26 UTC 2013 i686 i686 i686 GNU/Linux
$ sbcl --eval '(print *features*)' --quit

Jan Moringen (scymtym) wrote :

The attached patch causes the above FORMAT directive to signal an error when interpreted or compiled. A test case is included.

Stas Boukarev (stassats) wrote :

SBCL could use a better implementation of format, which allows for declarative definition of the number of arguments, their type, and allowed modifiers. And doesn't require to keep two definitions, one for the interpreter, one for the compiler. I'll commit the patch for now. Thanks.

Stas Boukarev (stassats) wrote :

commit 7b8eb24427562ae9e3ffe77e0a98899b9786e2b1
Author: Stas Boukarev <email address hidden>
Date: Sun Mar 10 20:15:53 2013 +0400

    format: Signal an error for ~<~@>

    CLHS doesn't allow @ to appear in the closing directive of ~<~>.

    Patch by Jan Moringen.

Changed in sbcl:
status: New → Fix Committed
Stas Boukarev (stassats) on 2013-03-31
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers