-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
year 2038 bug in POSIX::mktime #21551
Comments
|
You may want to compile with |
|
I tried
Back on my 32-bit cpu, the bug is in Perl's mktime, not in C's. My C code is, The C code outputs the correct dates, (The numbers on the left side depend on your time zone; I'm in America/New_York.) |
|
I guess we could make POSIX use floats for time, we already do this in some other places. But, to be honest, I would much rather just remove support for 32-bit IVs. It's a much cleaner solution. |
I don't think it's helpful to remove it entirely, but I do think it's fair to say that people who choose them get to deal with the consequences. I do think we should make |
If IV is a 32-bit type, but time_t is bigger, then it is possible for mktime() to return values outside the 32-bit range (> 0x7fff_ffff after 2038-01-19). In that case, fall back to NV (i.e. floating point). A double-precision floating point number provides more than 52 bits of precision, which should be plenty. Fixes Perl#21551.
If IV is a 32-bit type, but time_t is bigger, then it is possible for mktime() to return values outside the 32-bit range (> 0x7fff_ffff after 2038-01-19). In that case, fall back to NV (i.e. floating point). A double-precision floating point number provides more than 52 bits of precision, which should be plenty. Fixes #21551.
I agree, but only when the OS is known to support it in the given configuration |
We're using different distros. Adélie Linux, NetBSD, OpenBSD don't enable -Duse64bitint. I checked by running Fedora doesn't count; I can't find a 32-bit Fedora. We now have 2 out of 5 known distros using -Duse64bitint, more than "never", but less than "most".
If we want -Duse64bitint by default, how it would we make it happen? |
Module: POSIX
Description
On my old 32-bit powerpc, POSIX::mktime overflows from January 2038
to December 1901. I guess it's because ivsize=4.
Time::Local::timelocal_posix doesn't have this bug.
Steps to Reproduce
Expected behavior
This script should show the days 17 to 21 in January 2038, but I see
wrong days in 1901:
Flags
Perl configuration
The text was updated successfully, but these errors were encountered: