TRandom3::SetSeed(), strange behavior

Dear Root-Experts,

(Root 5.22/00)

I would like to report a behavior of TRandom3::SetSeed(UInt_t seed = 0) in interpreted mode, which I didn’t expect. I am not sure if this is a bug or a feature.

The following macro demonstrates the problem:

#include <TRandom3.h> #include <iostream> void RandomTest(){ // TRandom3 * randomGen = new TRandom3(0); // randomGen->SetSeed(0); cout<<" seed1: "<< randomGen->GetSeed()<<endl; // randomGen->SetSeed(); cout<<" seed2: "<< randomGen->GetSeed()<<endl; // }

The expected output looks like this:

root RandomTest.C++ root [0] Processing RandomTest.C++... Info in <TUnixSystem::ACLiC>: creating shared library /misc/home/he/aadametz/./ seed1: 1249051090 seed2: 1249051090

But when the macro is run in interpreted mode

~> root RandomTest.C root [0] Processing RandomTest.C... seed1: 1249051092 seed2: 65539

seed2 is 65539, which is the default value in TRandom::SetSeed(UInt_t seed = 65539).

So somehow the SetSeed method of TRandom is picked up, instead of the TRandom3-version, when SetSeed() is used without explicitly specified argument.

Best regards,

Hi Aleks,

This is an unfortunate (but unavoidable) consequence of a space optimization in the CINT dictionary. The CINT dictionary do not explicitly record the overload in derived class … and thus do not record changes in the default values either (if the base overload and the derived overload have different default value like TRandom and TRandom3).


Hi Philippe,

thank you for the quick answer. I didn’t know about that limitation of CINT.