Hello,
The following example from section 10 of the cffi documentation is causing a segmentation fault on clisp on cygwin:
(defcfun "sprintf" :int (str :pointer) (control :string) &rest)
CFFI> (with-foreign-pointer-as-string (s 100) (sprintf s "%c %d %.2f %s" :char 90 :short 42 :float 3.1415 :string "super-locrian")) => "A 42 3.14 super-locrian"
I replaced :float pi with :float 3.1415, as ``pi'' is long-float - I wanted to remove this as a possible cause.
At first I thought it was the %s for the string, but it may actually be the %.2f. - By itself %f, it does not correctly process floats, emitting ``f''. - If followed by other codes, it swallows them - If followed by a string, causes a segmentation fault
CL-USER> (cffi:with-foreign-pointer-as-string (s 100) (sprintf s "%s" :string "super-locrian")) "super-locrian"
CL-USER> (cffi:with-foreign-pointer-as-string (s 200) (sprintf s "%.2f" :float 3.1415)) "f"
CL-USER> (cffi:with-foreign-pointer-as-string (s 200) (sprintf s "%.2f %c" :float 3.1415 :char 65)) "f "
CL-USER> (cffi:with-foreign-pointer-as-string (s 200) (sprintf s "%.2f %s %c" :float 3.1415 :string "five" :char 65)) Segmentation fault
I'll try this on Linux/SBCL when I get back to work on Monday.
Mirko