Gevis Inko
2013-Oct-05 19:48 UTC
[Rd] Compiler warning: function returns address of local variable
I am a Gentoo user. I have just upgraded my Gentoo system, as I usually do every Saturday. During this process, my previous dev-lang/R-2.10.1 ebuild package has been upgraded to R-3.0.1. While compiling it, I have got the following compiler warning: * QA Notice: Package triggers severe warnings which indicate that it * may exhibit random runtime failures. * main.c:1548:5: warning: function returns address of local variable [enabled by default] * Please do not file a Gentoo bug and instead report the above QA * issues directly to the upstream developers of this software. * Homepage: http://www.r-project.org/ The Bug Tracking page of www.r-project.org simply do not open. So, I've just subscribed to this mailing list to post this compiler warning here. [[alternative HTML version deleted]]
Prof Brian Ripley
2013-Oct-07 07:05 UTC
[Rd] Compiler warning: function returns address of local variable
On 05/10/2013 20:48, Gevis Inko wrote:> I am a Gentoo user. I have just upgraded my Gentoo system, > as I usually do every Saturday. During this process, my previous > dev-lang/R-2.10.1 ebuild package has been upgraded to R-3.0.1. > While compiling it, I have got the following compiler warning: > > * QA Notice: Package triggers severe warnings which indicate that it > * may exhibit random runtime failures. > * main.c:1548:5: warning: function returns address of local variable > [enabled by default] > > * Please do not file a Gentoo bug and instead report the above QA > * issues directly to the upstream developers of this software. > * Homepage: http://www.r-project.org/ > > The Bug Tracking page of www.r-project.org simply do not open.It was down for a few days whilst the hardware was moved to another site. It is up now at https://rbugs.urbanek.info/bugzilla3/, and hopefully will be available again as bugs.r-project.org today.> So, I've just subscribed to this mailing list to post this compiler > warning here. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-develThat is the whole point of that piece of C code, so please do report the Gentoo bug (their message is simply bogus) to them. And also read posting guide before posting: HTML mail is not allowed here. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Radford Neal
2013-Oct-07 11:06 UTC
[Rd] Compiler warning: function returns address of local variable
> > ..., my previous > > dev-lang/R-2.10.1 ebuild package has been upgraded to R-3.0.1. > > While compiling it, I have got the following compiler warning: > > > > * QA Notice: Package triggers severe warnings which indicate that it > > * may exhibit random runtime failures. > > * main.c:1548:5: warning: function returns address of local variable > > [enabled by default] > > > > * Please do not file a Gentoo bug and instead report the above QA > > * issues directly to the upstream developers of this software. > > * Homepage: http://www.r-project.org/> That is the whole point of that piece of C code, so please do report the > Gentoo bug (their message is simply bogus) to them. > > And also read posting guide before posting: HTML mail is not allowed here. > > -- > Brian D. Ripley, ripley at stats.ox.ac.ukThe message is certainly not "simply bogus". Returning the address of a local variable is almost always a bug. In this case, there is no real bug in R-3.0.1, since the result is used for the low-level, system-dependent operation of determining the direction of stack growth, but this is a very rare use. For the compiler to issue such a warning is fully justified. The warning could be avoided by using the approach taken in pqR, which has the following routine in main.c: /* Detemine whether the stack grows down (+1) or up (-1). Passed the address of a local variable in the caller's stack frame. This is put here, though called only from system.c, so that the compiler will not be able to inline it. */ int R_stack_growth_direction (uintptr_t cvaraddr) { int dummy; return (uintptr_t) &dummy < cvaraddr ? 1 : -1; }