kit icon indicating copy to clipboard operation
kit copied to clipboard

Please don't use `Rboolean` for elements of logical vectors

Open aitap opened this issue 9 months ago • 1 comments
trafficstars

Hello!

A recent R-devel thread prompted me to go looking for Rboolean-related problems on CRAN and I found one in your package. The Rboolean type is only intended to hold TRUE and FALSE enumeration constants; while it currently happens to work well with logical values from R vectors, it may break in the future (and was briefly broken on R-devel if your package included stdbool.h or was compiled by a C23 compiler).

To avoid the problem, use something like sizeof(*LOGICAL(ans)) here: https://github.com/2005m/kit/blob/8bfe825e6611dc543281055a272373f58fe71c9b/src/utils.c#L390

Since LOGICAL() values are ints, you can also combine the case LGLSXP : and case INTSXP : branches.

aitap avatar Feb 06 '25 15:02 aitap