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.