[Rd] Illegal Logical Values

Radford Neal radford at cs.toronto.edu
Sat Oct 21 16:14:27 CEST 2017


> On Fri, 2017-10-20 at 14:01 +0000, brodie gaslam via R-devel wrote:

> > I'm thinking of this passage:
> > 
> > > Logical values are sent as 0 (FALSE), 1 (TRUE) or INT_MIN =
> > > -2147483648 (NA, but only if NAOK is true), and the compiled code
> > > should return one of these three values. (Non-zero values other
> > > than INT_MIN are mapped to TRUE.) 
> > 
> > The parenthetical seems to suggest that something like 'LOGICAL(x)[0]
> > = 2;' will be treated as TRUE, which it sometimes is, and sometimes
> > isn't:
> 
> From: Martyn Plummer <plummerm at iarc.fr>

> The title of Section 5.2 is "Interface functions .C and .Fortran" and
> the text above refers to those interfaces. It explains how logical
> vectors are mapped to C integer arrays on entry and back again on exit.
> 
> This does work as advertised. 


Not always.  As I reported on bugzilla three years ago (PR#15878), it
only works if the logical argument does not have to be copied.  The
bug has been fixed in pqR since pqR-2014-09-30.

   Radford Neal



More information about the R-devel mailing list