Skip to content

DiagonalMatrix: clang optimisation upsets the inverse function

For

clang version 13.0.1
Target: x86_64-suse-linux-gnu
Thread model: posix

The if-block in DiagonalMatrix.C#L160 triggers FPE for mag(val) < VSMALL:

    for (const Type& val : mat)
    {
        if (mag(val) < VSMALL)
        {
            *iter = Zero;
        }
        else
        {
            *iter = Type(1)/val;
        }

        ++iter;
    }

The reason is likely that *iter = Type(1)/val; and *iter = Zero; are evaluated before the condition mag(val) < VSMALL).