From radford at cs.toronto.edu  Sat Jul 13 16:59:29 2013
From: radford at cs.toronto.edu (Radford Neal)
Date: Sat, 13 Jul 2013 10:59:29 -0400
Subject: [Rd] missing PROTECT() in src/main/arithmetic.c
In-Reply-To: <mailman.27.1373709607.15244.r-devel@r-project.org>
References: <mailman.27.1373709607.15244.r-devel@r-project.org>
Message-ID: <20130713145929.GA4321@cs.toronto.edu>

> 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



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