Someone wrote something like: int32_t ticks; // 100ths of a second
which overflows in 248 days, a particularly unfortunate amount of time because it doesn't show up during testing.Although it would be a good engineering choice, a formal verifier would say that: int64_t ticks; // 100ths of a second
is also incorrect, since it also overflows (after 10^9 years).In a hard real time system, mpz_t ticks; // 100ths of a second, infinite precision libgmp type
is still formally incorrect, since as the the number grows in size it will eventually exceed a time limit or memory (after 10^10^9 years)The overall lesson from formal methods is that it's impossibly to write formally correct useful programs. So programmers just muddle through. |
If the algorithms really depend on an always monotonously increasing tick-counter (which I doubt), the solution is quite easy: After 2^30 ticks set a flag which raises the "service needed" light in the cockpit, taking the plane out of service until it's power cycled. By this you explicitly state that your device cannot be used longer than 120 days continuously.