Re: array type declaration problems
Gary Byers <[email protected]> Wed, 24 Sep 2003 01:08:28 -0600 (MDT)
| Newsgroups | gmane.lisp.openmcl.bugs |
|---|---|
| Message-ID | <[email protected]> |
On Sun, 21 Sep 2003, james anderson wrote: > > this function > > (defun matrix-identity (&optional (nm (matrix) result-p)) > "initialize an optional argument matrix to the diagonal = 1.0d0. > if no result matrix is provided a new matrix is constructed." > #|(declare (optimize (speed 3) (safety 0)) (type double-matrix nm))|# > (when result-p (assert-type nm double-matrix)) > (let ((i-max (array-dimension nm 0)) > (j-max (array-dimension nm 1))) > (declare (type fixnum i-max j-max)) > (dotimes (i i-max) > (dotimes (j j-max) > (if (= i j) > (setf (aref nm i j) 1.0d0) > (when result-p ; a defaulted result is > already initialized > (setf (aref nm i j) 0.0d0)))))) > nm) > > produces incorrect result if the type declaration is included. > independent of the optimize declaration. > Sorry for not responding sooner. This is fixed in CVS. The compiler was sort of unsure about whether or not (SETF (AREF a i j) ...) has side-effects, so it generated correct code and a branch instruction that skipped that code completely.