[Openmcl-devel] Today's WTF moment
Gary Byers
gb at clozure.com
Sun Apr 10 21:25:20 PDT 2016
So ...
Calls to (%INT-TO-PTR X) where X is recognized as a constant-valued
negative integer
have been quietly compiled as (something like) (%INT-TO-PTR (logand x
all-ones)) for
several (probably more than 5, possibly less than 10) years
In cases where X is not an n-bit integer constant, the generated code is
the same as
it had been.
I don't remember whether calls to (%INT-TO-PTR -1) errored at
compile-time before this
change, warned at compile-time, or merely errored at run-time.
On 04/10/2016 01:48 PM, Ron Garret wrote:
> ? (funcall (lambda () (%int-to-ptr -1)))
> #<A Foreign Pointer #xFFFFFFFFFFFFFFFF>
>
> ? (let ((x -1)) (%int-to-ptr x))
> #<A Foreign Pointer #xFFFFFFFFFFFFFFFF>
>
> But...
>
> ? (%int-to-ptr -1)
>> Error: The value -1 is not of the expected type (UNSIGNED-BYTE 64).
> ? (loop for x in '(-1) collect (%int-to-ptr x))
>> Error: The value -1 is not of the expected type (UNSIGNED-BYTE 64).
> ? (loop for x in '(-1) collect (let ((y x)) (%int-to-ptr y)))
>> Error: The value -1 is not of the expected type (UNSIGNED-BYTE 64).
> ? (loop for x in '(-1) collect (funcall (lambda () (%int-to-ptr x))))
>> Error: The value -1 is not of the expected type (UNSIGNED-BYTE 64).
> ? (defun foo (x) (%int-to-ptr x))
> FOO
> ? (foo -1)
>> Error: The value -1 is not of the expected type (UNSIGNED-BYTE 64).
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel
More information about the Openmcl-devel
mailing list