From radford at cs.toronto.edu  Sat Oct 21 16:14:27 2017
From: radford at cs.toronto.edu (Radford Neal)
Date: Sat, 21 Oct 2017 10:14:27 -0400
Subject: [Rd] Illegal Logical Values
In-Reply-To: <mailman.9.1508580002.48586.r-devel@r-project.org>
References: <mailman.9.1508580002.48586.r-devel@r-project.org>
Message-ID: <20171021141427.GA6941@mail.cs.toronto.edu>

> 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



[Rd] Illegal Logical Values
Radford Neal