[Bug libstdc++/108409] New: std::chrono::current_zone() doesn't work on AIX
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Jan 14 19:08:15 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409
Bug ID: 108409
Summary: std::chrono::current_zone() doesn't work on AIX
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
Target: *-*aix*
terminate called after throwing an instance of 'std::runtime_error'
what(): tzdb: cannot determine current zone
FAIL: std/time/tzdb/1.cc execution test
terminate called after throwing an instance of 'std::runtime_error'
what(): tzdb: cannot determine current zone
FAIL: std/time/zoned_time/custom.cc execution test
The std::chrono::current_zone() function is supposed to determine the machine's
time zone. As noted in libstdc++-v3/src/c++20/tzdb.cc:
// TODO AIX stores current zone in $TZ in /etc/environment but the value
// is typically a POSIX time zone name, not IANA zone.
// https://developer.ibm.com/articles/au-aix-posix/
// https://www.ibm.com/support/pages/managing-time-zone-variable-posix
__throw_runtime_error("tzdb: cannot determine current zone");
How should we solve this?
We should parse the TZ env var and see if it is already an IANA name, and
handle a few other special cases. E.g. gcc119 in the cfarm hax TZ=CUT0 which
means a time zone named "CUT" (coordinated universal time) with a 0 offset from
UTC. So map to UTC. More generally, "FOOn" is a time zone called "FOO" with a
-n offset, so we could map any such string to "Etc/GMT-n"
We could add some AIX-specific extension point, so programs can tell the
library the IANA (aka Olson) name of the current time zone. Maybe read it from
another file, something configurable and controlled by the user/program. But if
we handle the TZ variable, users can just set that in their program's env and
another extension point probably isn't needed.
More information about the Gcc-bugs
mailing list