Is there a reliable way to check for overflow before addition, without casting to a bigger type, or go into assembly to check the carry flag?
If I understand it correctly, the classic way -
is not reliable since overflow is not defined, and the compiler can and do optimize the check away.Code:u32 a;
if ((a+10) < 10) //overflow