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
This is a minor issue but I just thought I'd bring it up. When compiling KPP 3.1.1 with gcc 10.2.0, I get this warning:
C_rk_Integrator.c: In function ‘RK_Integrator’:C_rk_Integrator.c:1045:34: warning: ‘ErrOld’ may be used uninitialized in this function [-Wmaybe-uninitialized] 1045 | FacGus = FacSafe*(H/Hacc)*pow(Err*Err/ErrOld,(double)(-0.25)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C_rk_Integrator.c:1045:27: warning: ‘Hacc’ may be used uninitialized in this function [-Wmaybe-uninitialized] 1045 | FacGus = FacSafe*(H/Hacc)*pow(Err*Err/ErrOld,(double)(-0.25)); | ~~^~~~~~
Which I've traced to this section of code:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*//*~~~> Accept/reject step *//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/// accept:if (Err<ONE) { /*~~~> STEP IS ACCEPTED */FirstStep=0;
ISTATUS[Nacc]++;
if (Gustafsson==1) {
/*~~~> Predictive controller of Gustafsson */if (ISTATUS[Nacc] >1) {
FacGus=FacSafe*(H/Hacc)*pow(Err*Err/ErrOld,(KPP_REAL)(-0.25));
FacGus=MIN(FacMax,MAX(FacMin,FacGus));
Fac=MIN(Fac,FacGus);
Hnew=Fac*H;
} /* end if */Hacc=H;
ErrOld=MAX((KPP_REAL)1.0e-02,Err);
} /* end if */
The compiler is flagging that ErrOld may be uninitialized. It doesn't look like it's used until after the first timestep.
Would it be safe to set e.g. ErrOld = Err just after the FirstStep=0 line? That would remove the warning.
Also a similar situation is in the F90 code but we don't get a warning for that.
This isn't an essential fix but would be more of a cleanup so that we wouldn't generate warnings when building the mechanism.
The text was updated successfully, but these errors were encountered:
The code seems to be written in a way that ErrOld is never
uninitialized: ISTATUS starts with zero. It is then incremented to 1,
meaning that if (ISTATUS[Nacc] > 1) is still false and ErrOld is not
used yet. Anyway, in the spirit of clean coding, I agree that ErrOld
should be initialized with a dummy value.
I don't think that after FirstStep=0 is the right place. To be on the
safe side, I'd put it at the very beginning of the function, i.e.,
before Tdirection = SIGN....
For consistency, I think that the f90 code should be adjusted as well.
This is a minor issue but I just thought I'd bring it up. When compiling KPP 3.1.1 with gcc 10.2.0, I get this warning:
Which I've traced to this section of code:
The compiler is flagging that
ErrOld
may be uninitialized. It doesn't look like it's used until after the first timestep.Would it be safe to set e.g.
ErrOld = Err
just after theFirstStep=0
line? That would remove the warning.Also a similar situation is in the F90 code but we don't get a warning for that.
This isn't an essential fix but would be more of a cleanup so that we wouldn't generate warnings when building the mechanism.
The text was updated successfully, but these errors were encountered: