MrBayes icon indicating copy to clipboard operation
MrBayes copied to clipboard

Variable 'j' may be uninitialized when used here

Open zhangchicool opened this issue 4 years ago • 2 comments

in mcmc.c, line 12987,
if (p->nValues == 1 && strcmp(mp->symPiPr,"Fixed") != 0) { SafeSprintf (&tempStr, &tempStrSize, "\t%s", MbPrintNum(sst[j])); if (AddToPrintString (tempStr) == ERROR) goto errorExit; }

there is a warning: "Variable 'j' may be uninitialized when used here"

This is likely a bug.

zhangchicool avatar Aug 05 '20 01:08 zhangchicool

Related to commit bcda39b4

kusalananda avatar Aug 05 '20 06:08 kusalananda

I think it is safe to delete in else if (p->paramType == P_PI || p->paramType == P_MIXTURE_RATES)

that

if (p->nValues == 1 && strcmp(mp->symPiPr,"Fixed") != 0)
                {
                SafeSprintf (&tempStr, &tempStrSize, "\t%s", MbPrintNum(sst[j]));
                if (AddToPrintString (tempStr) == ERROR) goto errorExit;
                }

as this condition is never satisfied. @ronquist should be able to easily verify this suggestion.

zhangchicool avatar May 12 '22 00:05 zhangchicool