@craigmaloney why is there a 2038 bug??!!
@operand @craigmaloney This is interesting: "The C programming language allows for aggressive compiler optimization: a program can operate differently or even have a different control flow than the source code, as long as it exhibits the same user-visible side-effects, if undefined behavior never happens during program execution."
@micrackbiron @craigmaloney Well, it seems weird, but it makes sense. A program is, after all, an expression in some formal language. The modern need for speed has changed that formal language from one which describes what a computer does to one that describes the result one wants in a roundabout way.
Undefined behavior just makes this more "fun". There's an immense amount of writing on all the weird shit that UB does in C and C++ and I'm sure there are people here that are more experienced in it than I am.
Say that you use a 32-bit *unsigned* integer instead. For unsigned integers, putting in a value larger than its maximum value is well-defined: the value is simply taken modulo 2^32, so adding one to the maximum value results in 0. Your program is probably still broken if that integer was measuring time, even though there isn't any undefined behavior.
The fact that signed integer rollover is undefined simply makes the problem a little worse than it would otherwise be.
Server run by the main developers of the project It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!