Thanks for reporting.<br><br>The cause of the problem was not related to safety levels but rather how variables are incremented. LOOP uses a SETF statement with a THE around the new value. Your examples were using a bare SETF form (or INCF, which translates into something similar).<br>
<br>That would have no further consequences, but it turns out that ECL's macroexpander was not optimizing the SETF form. Instead,<br><br>(SETF I (1+ I)) -> (LET ((X (1+ I))) (SETQ I X)<br><br>as you see in the macroexpanded version there is no direct enforcement of X to be fixnum and thus no possible optimization.<br>
<br>I have fixed SETF to at least recognize the simple case in which there are only variables involved and not multiple temporary values. Now the behavior should be as you expected<br><br>> (disassemble '(lambda (x) (declare (optimize (safety 0))) (let ((i x)) (declare (fixnum i)) (incf i) (if (> i 3) (print 2)))))<br>
<br>;;; Compiling (DEFUN C::GAZONK ...).<br>;;; Emitting code for C::GAZONK.<br>/* function definition for GAZONK */<br>/* optimize speed 3, debug 0, space 0, safety 0 */<br>
static cl_object L1c__gazonk(cl_object V1)<br>{ VT2 VLEX2 CLSR2 STCK2<br> const cl_env_ptr cl_env_copy = ecl_process_env();<br> cl_object value0;<br>TTL:<br> {cl_fixnum V2; /* I */<br>
V2= fix(V1);<br> V2= (V2)+(1);<br> [...]<br><br>Best<br><br>Juanjo<br clear="all">
<br>-- <br>Instituto de Física Fundamental, CSIC<br>c/ Serrano, 113b, Madrid 28006 (Spain) <br><a href="http://juanjose.garciaripoll.googlepages.com" target="_blank">http://juanjose.garciaripoll.googlepages.com</a><br>