[Rd] Suggestion to emphasize Rboolean is unrelated to LGLSXP in R-exts
Ivan Krylov
|kry|ov @end|ng |rom d|@root@org
Sun Feb 2 16:50:58 CET 2025
The good news is that without a C23-enabled compiler, the problem will
only happen to source files that #include <stdbool.h>. The bad news is
that such a source file will technically disagree with the rest of R
about the type of Rboolean, including the prototypes of the API
functions that accept Rboolean:
#include <stdbool.h>
#include <Rinternals.h>
typedef void (*pordervector1)(int *, int, SEXP, Rboolean, Rboolean);
// ...
pordervector1 f = R_orderVector1;
f(pindx, length(indx), arg, nalast, decreasing);
foo.c:27:17: runtime error: call to function R_orderVector1 through
pointer to incorrect function type 'void (*)(int *, int, struct SEXPREC
*, bool, bool)'
/tmp/R-devel/src/main/sort.c:1135: note: R_orderVector1 defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior foo.c:27:17
With sanitizers disabled, this doesn't seem to cause any real problems
thanks to the calling convention, where both 'enum's and 'bool's are
passed and returned in a register.
--
Best regards,
Ivan
More information about the R-devel
mailing list