Skip to content
Prev 18572 / 21312 Next

[Bioc-devel] [External] Re: Strange "internal logical NA value has been modified" error

Hi Pariksheet,

Interesting, and thanks for sharing.

Note that a situation where it's actually safe to modify R values passed 
to C is when you allocate the vector in R right before going to C. For 
example in your case I think that doing something like

     converged <- logical(1)

     converged[1] <- NA

     .Call(C_train,

           PACKAGE = "tsshmm",

           converged,

           ...

would have been ok.

That being said, it's certainly better style to stick to the "treat R 
values passed to C as read-only" rule, especially since it's almost 
always easy to do (in my experience). For example in your case, there's 
no need for the 'converged' argument. You could simply create this SEXP 
at the C level and have your .Call entry point return it, as I'm sure 
you figured out already.

Best,
H.
On 16/10/2021 08:54, Pariksheet Nanda wrote: