Skip to content
Snippets Groups Projects
Commit 5fc2d92b authored by rtoy's avatar rtoy
Browse files

Fix critical bug in realpart/imagpart.

o realpart/complex-single-float, realpart/complex-double-float,
  imagpart/complex-double-float, %complex-double-float, and
  %complex-single-float were zeroing out the result register
  which is ok, except when the result register and the source register
  are the same.  Use a temp register in this case.

  This bit of code tickles the bug:

    (defun zot-r (z)
      (declare (type (simple-array (complex double-float) (*)) z))
      (realpart (aref z 0)))

    (defun zot-i (z)
      (declare (type (simple-array (complex double-float) (*)) z))
      (imagpart (aref z 0)))

    (let ((z (make-array 1 :element-type '(complex double-float)
			 :initial-element #c(42d0 -42d0))))
      (zot-r z))

    (let ((z (make-array 1 :element-type '(complex double-float)
			 :initial-element #c(42d0 -42d0))))
      (zot-i z))

  The correct results are 42d0 and -42d0, not 0d0, of course.
parent a1effa94
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment