[Openmcl-devel] psetf issue on Linux|Windows X8632
lsxvdqe
lsxvdqe at gmail.com
Thu Apr 13 06:28:23 PDT 2017
Also reproduced with CCL 1.12 FreeBSDX8632. 64-bit isn't affected.
I've tried to simplify test case further from macroexpansion and found this.
Just one slot:
(defstruct vec
(x 0.0 :type single-float))
Simplest failure case:
(let ((v (make-vec)))
(setf (values (vec-x v)) 1.0))
Macroexpansion of this is similar to psetf, so let's try something low-level.
Following forms WORK:
(let ((v (make-vec)))
(ccl::struct-set v 1 1.0))
(let ((v (make-vec))
(x 1.0))
(ccl::struct-set v 1 x))
(let ((v (make-vec)))
(ccl::struct-set v 1 (ccl::typecheck 1.0 single-float)))
(let ((v (make-vec))
(x 1.0))
(ccl::struct-set v 1 (ccl::typecheck x single-float)))
(let ((v (make-vec))
(x 1.0))
(ccl::struct-set v 1 (ccl::typecheck x single-float)))
(let ((v (make-vec)))
(let ((x (ccl::typecheck 1.0 single-float)))
(ccl::struct-set v 1 x)))
(let ((v (make-vec))
(x 1.0))
(setf x (ccl::typecheck x single-float))
(ccl::struct-set v 1 x))
This FAILS:
(let ((v (make-vec))
(x 1.0))
(let ((x (ccl::typecheck x single-float)))
(ccl::struct-set v 1 x)))
This also FAILS:
(let ((v (make-vec))
(x 1.0))
(let ((x (identity (ccl::typecheck x single-float))))
(ccl::struct-set v 1 x)))
While this WORKS fine again:
(let ((v (make-vec))
(x 1.0))
(let ((x (values (ccl::typecheck x single-float))))
(ccl::struct-set v 1 x)))
(let ((v (make-vec))
(x 1.0))
(let ((x (print (ccl::typecheck x single-float))))
(ccl::struct-set v 1 x)))
(let ((v (make-vec))
(x 1.0))
(let ((x (ccl::typecheck x single-float)))
(ccl::struct-set v 1 (print x))))
Maybe someone can make sense of disassembling this?
On Wed, 12 Apr 2017, Shannon Spires wrote:
> I can reproduce it on my Mac in CCL32, but not CCL64. Furthermore, it only happens in CCL32 when safety is 1 or 0.
>
> (defstruct vec
> (x 0.0 :type single-float)
> (y 0.0 :type single-float))
>
> ; Following has the psetf form macroexpanded for greater clarity:
>
> (defun test ()
> (declare (optimize (safety 1))) ; no error when 2 or 3
> (let ((vec (make-vec)))
> (PROGN (LET ((foo (CCL::STRUCTURE-TYPECHECK VEC VEC)))
> (MULTIPLE-VALUE-BIND (bar)
> 5.0
> (PROGN (SETF (VEC-Y VEC) 5.0)
> (THE SINGLE-FLOAT
> (LET ((bar (CCL::TYPECHECK bar SINGLE-FLOAT)))
> (CCL::STRUCT-SET foo 1 bar))))))
> vec)))
>
> (test)
>
>
> On Apr 12, 2017, at 9:48 AM, Ron Garret wrote:
>
>> Seems to be Windows-specific. I can’t reproduce this on my mac.
>>
>> On Apr 12, 2017, at 2:30 AM, Nicolas Hafner <shinmera at tymoon.eu> wrote:
>>
>>> This case can be further reduced to the following, which does not require the library:
>>>
>>>
>>> (defstruct vec
>>> (x 0.0 :type single-float)
>>> (y 0.0 :type single-float))
>>>
>>> (let ((vec (make-vec)))
>>> (psetf (vec-x vec) 5.0
>>> (vec-y vec) 5.0))
>>>
>>> The specific trigger combination seems to be psetf with typed structure slots.
>>>
>>> On 12/04/17 11:20, gzip4 wrote:
>>>> Hello, All!
>>>>
>>>> To reproduce the issue:
>>>>
>>>>
>>>> (lisp-implementation-version)
>>>> "Version 1.11-r16635 (WindowsX8632)"
>>>>
>>>> (ql:quickload '3d-vectors)
>>>>
>>>> (let ((vec (3d-vectors::vec 5 0 0)))
>>>> (psetf (3d-vectors::%vx3 vec) 5.0
>>>> (3d-vectors::%vy3 vec) 5.0))
>>>>
>>>> Signal error:
>>>> The value 5.0 is not of the expected type STRUCTURE.
>>>> [Condition of type TYPE-ERROR]
>>>>
>>>> The problem seems to be related to psetf. If you remove one of the set pairs, it works fine. If you use setf, it also works fine.
>>>>
>>>> 64 bit versions do not have such an issue, LinuxARM32 also passes.
>>>>
>>>> --
>>>> gzip4
>>>
>>> _______________________________________________
>>> Openmcl-devel mailing list
>>> Openmcl-devel at clozure.com
>>> https://lists.clozure.com/mailman/listinfo/openmcl-devel
>>
>> _______________________________________________
>> 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