mardi 16 octobre 2018

No return evaluation in nested if

After watching carefully the following code I can't see why the compiler is warning me with "warning: control reaches end of non-void function".

bool Foam::solidMagnetostaticModel::read()
{
    if (regIOobject::read())
    {
        if (permeabilityModelPtr_->read(subDict("permeability")) && magnetizationModelPtr_->read(subDict("magnetization")))
        {
            return true;
        }
    }
    else
    {
        return false;
    }
}

I can't see where is the problem, the else statement should care for returning false in every case which the first if is not true.

Aucun commentaire:

Enregistrer un commentaire