3 ms·
int Mid = (high + low) / 2; The above line is easy to formally prove correct. However it is wrong - if high + low is greater than int_max on your system you ha
by bluGill 3y ago
int Mid = (high + low) / 2;
The above line is easy to formally prove correct. However it is wrong - if high + low is greater than int_max on your system you have a bug.
I'm still in favor of formal proofs, but there are limits to what it can do.
- temac 3y agoYou don't model an unconstrained "int Mid = high + low / 2;" line of e.g. C code with the math equation "Mid = high + low / 2". There are limits but this is a poor example.
- bluGill 3y agoThis is a real world example. Code that was proved decades ago and worked has started failing now as computers are able to handle in memory datasets that large. (I probably got the parenthesis wrong on the original example)
- weinzierl 3y agoI don't know much about formal verification, but I had expected that it considers the most basic behaviour of the most basic data types we have at the very least. Integer overflow as one of wrap-around, saturation or invalid state (UB in the real world) is a bar so low that I do not know what formal verification that doesn't consider it would be useful for all.