Re: [Rd] Follow-Up: R on FC4

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Wed 03 Aug 2005 - 00:55:53 GMT

Peter Dalgaard <p.dalgaard@biostat.ku.dk> writes:

> Gavin Simpson <gavin.simpson@ucl.ac.uk> writes:
....
> > So far so good with FC4, gcc4, gfortran and R!
>
> The problem affecting the Fedora Extras RPM is still there with the
> new compilers though:
>
> -Wp,-D_FORTIFY_SOURCE=2
>
> combined with -O or -O2 causes a strange printing bug:
>
> > matrix(list(pi))
> [,1]
> [1,]
>
> (You don't have to use that option of course, but it suggests that not
> all is well with the optimizer. And the Fedora maintainer seem set on
> using it, which is a bit of a problem.)

I'm fairly sure by now that this is actually a bug in R, not gcc. We have the same internal buffer structure used in EncodeReal and in Rsprintf, and the return value of the former is buffer->data which is reallocated by the latter.

That means that constructions of the form

pbuf = Rsprintf("%s", EncodeReal(REAL(tmp)[0], w, d, e, OutDec));

are playing with fire. There are quite a few other similar constructions involving Encode*.

I suspect is is necessary to copy the result of EncodeReal(REAL(tmp)[0], w, d, e, OutDec) to temp storage, or - probably easier - use a separate buffer for Rsprintf.

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed Aug 03 10:59:00 2005

This archive was generated by hypermail 2.1.8 : Mon 24 Oct 2005 - 22:27:33 GMT