This has seemed to be an unpopular observation, in the past.
This has seemed to be an unpopular observation, in the past.
The other problem is that more unsafe code in libraries, etc, will happily cooperate with 2038-safe unsigned time_t code, but will start to do bad things shortly before 2038.
Wouldn’t it also fail for all code that
a) stores the return value in a plain int and not a time_t as it would truncate (but at least this is a warning)
b) has time_t inside struts and allocates their size or arrays of structs assuming time_t is 4 bytes
c) has time_t inside structs and assumes the byte alignment of fields following it
Etc etc..
B) -- manual calculation of size of structs instead of sizeof() -- yah, maybe it'll happen. I don't see much code this bad. If it's ever compiled on a different word length it's already been fixed.
C) Perhaps. For the most part alignment improves when you have a wider time_t, but you could have people counting the number of 32 bit fields and then needing 16 byte alignment for SSE later. Again, for the most part this penalty has been paid by code compiling on amd64, etc.
And lots of code would break because they want to talk about pre-1970 dates.
I'm definitely guilty of it, as I routinely use the timeline of the Great Emu War (1932-10-02/1932-12-10) to test time-bound features.
Now it's some in house protocol sure you can just update everything instead making the timestamp a relative value to the current era.
For code running locally 64 bits is less of issue, just mainly a problem of ABI breaks.
Honestly, one thing I think people overlook is file-formats... A lot them have 32 bit time fields. Also unlike a network packet the file could actually be from a previous 32 bit era. So those timestamps are ambiguous after 2038.
I'm also in favour of adopting IPv6 ASAP, but so far that has been a much harder sell.
time_t is sufficient within bounds. It is expedient and quite correct in many computer science use cases. It can be extended with small additions for many other use cases.
However those bounds are a set of assumptions and simplifications that shouldn't be forgotten. I agree that the problem would be solved until the next paradigm shift in our understanding of time and the universe, and maybe forever if it turns out that the rules are cruel or we're too stupid to reach a more complex situation. I just wouldn't say once and for all, there's far too much uncertainty there.
'bout the same as tomorrow really, better do nothing, for in the end all is dust.
You'll be in a much bigger universe, but it will be empty except for your local galaxy group.
E.g. you can't do...
time_t completion = time(NULL) + 30;
do {
time_t remaining = completion - time(NULL);
/* ... */
} while (remaining > 0);
Without risking a sporadic infinite loop. #include <stdint.h>
int64_t completion = (int64_t)time(NULL) + 30;
do {
int64_t remaining = completion - (int64_t)time(NULL);
/* ... */
} while (remaining > 0);
There’s some slowdown doing 64-bit int math on a 32-bit system, but the above works.