Jim Wise <jwise@...> writes:
> Made a little progress this afternoon. I'll try to write up what I've
> got so far later, but in short, where a struct being passed to
> define-c-struct has a member declared as char (not char *), sb-grovel
> is ending up expanding this:
> `(let* ((,stringvar ,string)
> (,upper-bound (or ,limit (1+ (length ,stringvar))))
> (,last-elt (min (1- ,upper-bound) (length ,stringvar)))
> (,octets (sb-ext:string-to-octets ,stringvar :end ,last-elt
> :null-terminate t))
> (,alien-ptr (cast ,alien (* unsigned-char))))
> in c-string-writer (through a convoluted method path) with `upper-bound'
> set to zero, and thus last-elt expands to `(1- upper bound)' i.e. (1- 0)
> cast to an index, i.e. the max unsigned value.
> On Solaris, this indeed happens twice -- once for struct dirent, and
> once for struct stat, but I'm not sure I understand the path that leads
> upper-bound to be 0, so I'm not close to how to fix this.
Actually, it's not dirent and stat, and it's not char -- it's dirent
twice, and it's because dirent is defined in constants.lisp with
`:distrust-length t' in the #+sunos case in order to deal with the old-style dirent
(declared as having it's last member a char which actually grows to
the size needed).
:distrust-length expands in sb-grovel's c-for-structure to output 0 as
size, and boom....