Steel Bank Common Lisp

(expt 0.0 0.0) does not signal the error

Reported by Roman Marynchak on 2010-04-29
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Low
Roman Marynchak
Nominated for Trunk by Roman Marynchak

Bug Description

This is okay:

(expt 0 0) -> 1

and this is bad:

(expt 0.0 0.0) -> 1.0

The last case should signal the arithmetic error, like CLISP and Lispworks do.

Tested with 1.0.37 on Win32.

Regards,
Roman

The fix of this bug is simple. As a first part, we should define a new condition (see the attachment).

The second part of the fix is to add the appropriate check in EXPT.

With these changes SBCL behaviour is the next:

* (expt 0.0 0.0)

debugger invoked on a SB-KERNEL::ARGUMENTS-OUT-OF-VALID-DOMAIN in thread #<THREAD
                                                                           "initial thread" RUNNING
                                                                           {AA158D1}>:
  arithmetic error SB-KERNEL::ARGUMENTS-OUT-OF-VALID-DOMAIN signalled
Operation was EXPT, operands (0.0 0.0).

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(EXPT 0.0 0.0)
0]

Modified accordingly to the discussion on sbcl-devel. The first part is here, the second in the next post.

After applying this patch, the next two cases

(expt 0.0 0.0)
(expt 0 0.0)

signal

debugger invoked on a SB-KERNEL::ARGUMENTS-OUT-OF-VALID-DOMAIN in thread #<THREAD
                                                                           "initial thread" RUNNING
                                                                           {A9EB801}>:
  arithmetic error SB-KERNEL::ARGUMENTS-OUT-OF-VALID-DOMAIN signalled
Operation was EXPT, operands (0 0.0).
See also:
  The ANSI Standard, Function EXPT

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

The regression test.

Changed in sbcl:
assignee: nobody → Roman Marynchak (roman-marynchak)
status: New → In Progress
Changed in sbcl:
importance: Undecided → Low
Nikodemus Siivola (nikodemus) wrote :

In SBCL 1.0.41.47.

Changed in sbcl:
status: In Progress → Fix Committed
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