Bug 15878 - Check for valid logical values from .C is broken
Summary: Check for valid logical values from .C is broken
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Language (show other bugs)
Version: R 3.1.0
Hardware: All All
: P5 normal
Assignee: R-core
Depends on:
Reported: 2014-07-11 19:47 UTC by Radford Neal
Modified: 2016-04-14 10:54 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Radford Neal 2014-07-11 19:47:46 UTC
Help for .C says that logical values returned are checked for validity, with anything other than TRUE, FALSE, and NA converted to TRUE.

Actually, no attempt to do this is done when DUP = FALSE.  If this is intended, it should be made clear in the documenation.

When DUP = TRUE, an attempt is made, but it works only if no duplication was needed (because NAMED was zero).  When a duplicate is made, the check for valid logical values mistakenly looks at the original vector, not the duplicate.

For example, with R-3.1.1 (or any version from R-2.15.1 on):

In test-docC-logical.c:   void test (int *a) { a[0] = 2; }


print (.C("test",a=c(T,F))$a)
print (.C("test",a=c(T,F))$a + 1)

x <- c(T,F)
print (.C("test",a=x)$a)
print (.C("test",a=x)$a + 1)

The last value printed has a "3", which shouldn't be possible from adding 1 to a logical value.