You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
R_CallMethodDef callMethods[] mostly don't specify the number of arguments. #7948
WRE 5.4 specifies that R can check the number of arguments given to .Call when invoking package-registered routines. (The actual code doing this is a bit scary, because FFI is hard.) This is important because calling a function through an incompatible function pointer is undefined behaviour in C. The exact consequences can range from almost harmless (the missing argument contains garbage, which you can ignore / the extra argument is just invisible to the function) to complete stack corruption and a quick crash.
Most functions registered for use with .Call in data.table specify -1 instead of the number of arguments. While I'm sure that all calls from R to C code in data.table currently use the correct number of arguments, explicitly specifying this will surface accidental future mistakes immediately instead of causing hard-to-debug crashes.
The old justification for this from Matt, IIRC, was just avoiding churn with making sure those numbers remain correct through the development life cycle.
I'm not compelled that that's a good reason to keep using -1 -- the API is relatively stable at this point, and we can easily write a linter to prevent backsliding if that's seen as a major concern.
Activity
MichaelChirico commentedon Oct 27, 2026
The old justification for this from Matt, IIRC, was just avoiding churn with making sure those numbers remain correct through the development life cycle.
I'm not compelled that that's a good reason to keep using
-1-- the API is relatively stable at this point, and we can easily write a linter to prevent backsliding if that's seen as a major concern.So +1 to making the change here.
aitap commentedon Oct 27, 2026
That's useful to know, thank you!