[Rd] missing PROTECT() in src/main/arithmetic.c

Radford Neal radford at cs.toronto.edu
Sat Jul 13 16:59:29 CEST 2013


> From: Herv? Pag?s <hpages at fhcrc.org>

> at lines 651 & 653 (integer_binary function):
> 
>      if (code == DIVOP || code == POWOP)
>          ans = allocVector(REALSXP, n);
>      else
>          ans = allocVector(INTSXP, n);
> 
> There are calls to warningcall() later in the function, which can
> trigger garbbage collection.
> 
> Looks like the typical scenario where it seemed pretty safe to not
> PROTECT in the original version of the function but became very
> unsafe 3 years later when the calls to warningcall() were added to
> the function.

Note that there is also a problem with a possible warning from myfmod,
which in turn is called from R_pow.  

The call of myfmod from R_pow should probably be replaced by something
else, since as it is, the following undesirable behaviour occurs:

    > (-Inf)^(1e16)
    [1] Inf
    Warning message:
    probable complete loss of accuracy in modulus 

I think issuing a warning for this is probably not a good idea, but if
a warning is issued, it certainly shouldn't be this one.

   Radford Neal



More information about the R-devel mailing list