Commit 9837aba8 authored by Andrew Heather's avatar Andrew Heather
Browse files

COMP: specie - ensure if block is evaluated

parent d0befa42
......@@ -159,14 +159,17 @@ inline specie operator==(const specie& st1, const specie& st2)
diffY = SMALL;
}
const scalar diffRW =
st2.Y_/st2.molWeight_ - st1.Y_/st1.molWeight_;
const scalar diffRW = st2.Y_/st2.molWeight_ - st1.Y_/st1.molWeight_;
scalar molWeight = GREAT;
if (mag(diffRW) > SMALL)
{
molWeight = diffY/diffRW;
}
// if (mag(diffRW) > SMALL)
// {
// molWeight = diffY/diffRW;
// }
// Using intermediate volatile bool to prevent compiler optimising out the
// if block (above) - CLANG 3.7.1
volatile const bool valid = (mag(diffRW) > SMALL);
const scalar molWeight = valid ? diffY/diffRW : GREAT;
return specie(diffY, molWeight);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment