Clozure / ccl

Clozure Common Lisp
http://ccl.clozure.com
Apache License 2.0
841 stars 105 forks source link

Asserting the type of NaN signals an error #441

Open eliaslfox opened 1 year ago

eliaslfox commented 1 year ago

On macOS using CCL Version 1.12.1 DarwinX8664

CL-USER> (typep 1d+-0 'double-float)
T
CL-USER> (the double-float 1d+-0)
; Evaluation aborted on #<FLOATING-POINT-INVALID-OPERATION #x302001351E0D>.
galdor commented 1 year ago

Same bug on Linux x86-64.

xrme commented 1 month ago

We end up calling zerop on the NaN value as part of turning the typespec into a ctype.

https://github.com/Clozure/ccl/blob/273dc1909889639fb32b592c0982983c8731beac/level-1/l1-typesys.lisp#L3062-L3075

To be honest, I am not sure what to do here.

LdBeth commented 2 days ago

Probably use ccl::nan-or-infinity-p to prevent zerop been called on nan.

However, zerop seems should not raise invalid operation exception on NaN at all, for the reason that compare quiet NaN with zero should just give false without signaling, but I'm not able to understand the assembly code to find out why the exception is raised for = with two double floats.