[cmucl-help] bugs in C::SOURCE-LOCATION and string reversal

Raymond Toy toy.raymond at gmail.com
Tue May 14 02:18:05 UTC 2013


>>>>> "Matt" == Matt Kaufmann <kaufmann at cs.utexas.edu> writes:

    Matt> Hi --
    Matt> I downloaded the 2013-05 snapshot from
    Matt> http://trac.common-lisp.net/cmucl
    Matt> (http://common-lisp.net/project/cmucl/downloads/snapshots/2013/05/cmucl-2013-05-x86-linux.tar.bz2),
    Matt> and I am running into two bugs, discussed below.  The first is kind of
    Matt> a show-stopper.  It's hit me before using CMUCL 19e (so I guess it's
    Matt> been around awhile), but at that time I was able to avoid it simply by
    Matt> not running my application in a particular "mode".  I'd appreciate any
    Matt> suggestions for easily working around that first bug.  I've worked
    Matt> around the second bug, but I thought I should report it, and I do so
    Matt> at the end, below.

First, sorry for the trouble you're having.  And thank you for
reporting it.  If you don't report it, it can't be fixed.

    Matt> The first bug pertains to C::SOURCE-LOCATION.  Below is part of the
    Matt> log, showing three errors during compilation followed by a break
    Matt> during load of the resulting compiled file.

Hmm.  There have been some issues with source-location, but I thought
they were fixed recently.  Apparently not.  Can I reproduce this by
downloading and installing acl2?  A short example file instead would
be better, but sometimes that's not so easy to do.

    Matt> I tried a workaround or two with the sort of approach I used below for
    Matt> the second error; but that didn't help.  Also, I don't care about
    Matt> source location information, but I didn't see a way simply to turn it
    Matt> off (as I do when compiling with CCL).

You never care to look at backtraces and see the offending source?  I
find that invaluable.

I don't know of any way to turn off source-location information
unfortunately.

    Matt> The second bug is in computing (reverse ""), as shown below.

Ouch.  This is probably due to a recent change in handling of strings.

For this particular issue, you can solve it with this:

(in-package "LISP")
(defmacro with-string (string &rest forms)
  `(let ((,string (if (stringp ,string) ,string (string ,string))))
     (with-array-data ((,string ,string)
		       (start)
		       (end (length (the vector ,string))))
       , at forms)))

(defun string-reverse* (sequence)
  (declare (optimize (speed 3) (space 0) (safety 0))
	   (type string sequence))
  (with-string sequence
    (let* ((length (- end start))
	   (string (make-string length))
	   (j length))
      (declare (type kernel:index length j))
      (when (plusp length)
	(loop for i = start then n as n = (%glyph-f sequence i) do
	  (replace string sequence :start1 (decf j (- n i)) :start2 i :end2 n)
	  while (< n end)))
      string)))

Ray



More information about the cmucl-help mailing list