logo       

Re: Typecheck hole in safety = 3, speed = 3 code: msg#00351

lisp.cmucl.devel

Subject: Re: Typecheck hole in safety = 3, speed = 3 code

Martin Cracauer <cracauer@xxxxxxxx> writes:

> Under certain conditions, a setf on a struct accessor does not check
> for the type of the assignment even under maximum safety.
>
> (declaim (optimize (safety 3) (debug 3) (speed 0)))
>
> (defstruct foo
> (bar 0 :type fixnum))
>
> (defun test (baz)
> (setf (foo-bar baz) "hello, world")
> baz)
>
> (print (foo-bar (test (make-foo))))
>
> ;; you get a compilation warning, but not a runtime error:

With CVS CMUCL, I get:

; In: defun test

; (setf (foo-bar baz) "hello, world")
; --> let* multiple-value-bind let funcall c::%funcall
; ==>
; #:g0
; Warning: This is not a (values &optional fixnum &rest t):
; "hello, world"
;
; (defun test (baz) (setf # "hello, world") baz)
; --> block
; ==>
; baz
; Note: Deleting unreachable code.
;

; Compilation unit finished.
; 1 warning
; 1 note


; /tmp/defstruct.x86f written.
; Compilation finished in 0:00:01.

; Loading #p"/usr/tmp/defstruct.x86f".

Type-error in kernel::object-not-type-error-handler:
"hello, world" is not of type fixnum
[Condition of type type-error]

Seems this is caught by one of the changes I made that were triggered
by Paul Dietz' tests.




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise