In my code I have a class named membrane
with a function named exciteMod()
, a function named decide()
and a variable named delta_U
. The first line of exciteMod()
is this->delta_U = 0
. In decide()
I have an exponent of -delta_U
(exp(-this->delta_U)
). which cause an error Use of uninitialised value of size 8. The only place where I call decide()
is inside of exciteMod()
. What might cause this? I don't have any error about delta_U
which is generated in valgrind.
Relevant segment of the code:
void membrane::exciteMod(){
this->delta_U = 0;
/* Do some stuff which does not directly affect this->delta_U*/
std::tr1::shared_ptr<bead> bit = this->beads.begin();
while (bit != this->nead.end()){
std::tr1::shared_ptr<bead> b = *bit++;
//calculate the doubles U and nextU on b, nothing here gives a warning in valgrind, anyhow U and nextU on b are always defined
this->delta_U += (b->nextU - b->U);
}
decide();
}
void membrane::decide(){
double r = P.r.ran3() // the random function from numerical recepies
double f = - this->delta_U;
if (r > exp(f)){ //this gives the warning even though delta_U is valid
/*stuff*/
}
}
This is the warning:
> ==467== Use of uninitialised value of size 8
> ==467== at 0x300B00D75D: __ieee754_exp (in /lib64/libm-2.5.so)
> ==467== by 0x300B022FA3: exp (in /lib64/libm-2.5.so)
> ==467== by 0x40BB9A: membrane::decide() (membrane.cpp:813)
> ==467== by 0x40EBB1: membrane::exciteMod() (membrane.cpp:639)
> ==467== by 0x413994: membrane::MCstep(int) (membrane.cpp:486)
> ==467== by 0x402767: main (main.cpp:14)