Le 21 août 2014 à 11:47, Gregor Kastner <gregor.kast...@wu.ac.at> a écrit :

> On Thu, 21 Aug 2014 11:34:23 +0200
> Romain Francois <rom...@r-enthusiasts.com> wrote:
> 
> GK> Yep, sorry for the misuse of language. And I do understand going back to
> GK> GetRNGstate() and PutRNGstate() is a bit old school; but I can definitely
> GK> confirm that it seems to be safer than resorting do the
> GK> constructor/destuctor magic.
>> 
>> Compiler/Destructor is not magic. It is determinism. 
>> 
>> That's like feature #1 of C++. 
> 
> agreed: s/magic/automagic/g
> 
>> And BTW it is definitely safer than any manual handling.  
> 
> I cannot say that in the current case, as relying on the destructor does seem
> to create problems (in rare cases, making it even worse!) if objects which
> are to be returned are instantiated after the RNGScope object. Conditional on
> the fact the I understood JJ correctly, that is.

Then it's a bug in how constructor or destructor is implemented in this class, 
probably with the counter. 

Or something invalidates the very assumptions of C++ here. Perhaps raw R api is 
called and the destructor is not called because of some long jump or something. 

Without a repex anyway, it is hard to diagnose what's happening. 

You're probably onto somthing, but going directly to the "destructor are not 
safe, I'll just use C function calls" is a dangerous route, soon you'll start 
using SEXP as you won't trust ctors/dtors of Rcpp objects do the right thing.

> Manual handling works perfectly.
> 
> Best,
> /g

_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to