public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/108409] New: std::chrono::current_zone() doesn't work on AIX
@ 2023-01-14 19:08 redi at gcc dot gnu.org
  2023-01-14 19:17 ` [Bug libstdc++/108409] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-14 19:08 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX
  2023-01-14 19:08 [Bug libstdc++/108409] New: std::chrono::current_zone() doesn't work on AIX redi at gcc dot gnu.org
@ 2023-01-14 19:17 ` redi at gcc dot gnu.org
  2023-01-14 21:59 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-14 19:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-01-14

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
describes the format of the TZ variable when it's not an IANA name.

When TZ does not name an IANA zone, we could potentially create a new
chrono::time_zone object, generated from the std and dst names, with the
appropriate offsets and DST transitions. Then current_zone() would return a
pointer to that custom zone.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX
  2023-01-14 19:08 [Bug libstdc++/108409] New: std::chrono::current_zone() doesn't work on AIX redi at gcc dot gnu.org
  2023-01-14 19:17 ` [Bug libstdc++/108409] " redi at gcc dot gnu.org
@ 2023-01-14 21:59 ` cvs-commit at gcc dot gnu.org
  2023-01-14 22:05 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-14 21:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:d80e5a7b30e5d045c808f5235123e366e4e9286c

commit r13-5170-gd80e5a7b30e5d045c808f5235123e366e4e9286c
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sat Jan 14 20:13:32 2023 +0000

    libstdc++: Implement std::chrono::current_zone() for AIX [PR108409]

    libstdc++-v3/ChangeLog:

            PR libstdc++/108409
            * src/c++20/tzdb.cc (current_zone()) [_AIX]: Use TZ environment
            variable.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX
  2023-01-14 19:08 [Bug libstdc++/108409] New: std::chrono::current_zone() doesn't work on AIX redi at gcc dot gnu.org
  2023-01-14 19:17 ` [Bug libstdc++/108409] " redi at gcc dot gnu.org
  2023-01-14 21:59 ` cvs-commit at gcc dot gnu.org
@ 2023-01-14 22:05 ` redi at gcc dot gnu.org
  2023-01-15 13:42 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-14 22:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #0)
> 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"

It now works if TZ contains an IANA time zone name, or any string matching
"???0". If the systemwide TZ isn't one of those, users can define TZ for their
own programs' environment.

I don't know if that's good enough.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX
  2023-01-14 19:08 [Bug libstdc++/108409] New: std::chrono::current_zone() doesn't work on AIX redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-01-14 22:05 ` redi at gcc dot gnu.org
@ 2023-01-15 13:42 ` redi at gcc dot gnu.org
  2023-01-15 13:56 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-15 13:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The current code doesn't work on Windows either.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX
  2023-01-14 19:08 [Bug libstdc++/108409] New: std::chrono::current_zone() doesn't work on AIX redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-01-15 13:42 ` redi at gcc dot gnu.org
@ 2023-01-15 13:56 ` redi at gcc dot gnu.org
  2023-01-15 13:58 ` redi at gcc dot gnu.org
  2023-11-06 17:26 ` [Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX or Windows mac at mcrowe dot com
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-15 13:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #4)
> The current code doesn't work on Windows either.

https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-gettimezoneinformation
only gives us the abbreviated names of the standard and daylight zones, e.g.
"EST" and "EDT". But those names are not unique and cannot be used to map to a
time zone, as the C++ standard points out in [time.zone.info.sys] p6:

"Abbreviations are not unique among the time_zones, and so one cannot reliably
map abbreviations back to a time_zone and UTC offset."

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX
  2023-01-14 19:08 [Bug libstdc++/108409] New: std::chrono::current_zone() doesn't work on AIX redi at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-01-15 13:56 ` redi at gcc dot gnu.org
@ 2023-01-15 13:58 ` redi at gcc dot gnu.org
  2023-11-06 17:26 ` [Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX or Windows mac at mcrowe dot com
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-15 13:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
https://learn.microsoft.com/en-gb/windows/win32/api/timezoneapi/nf-timezoneapi-getdynamictimezoneinformation?redirectedfrom=MSDN
has the same problem. I guess this is why MSVC uses ICU for its
std::chrono::tzdb implementation.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX or Windows
  2023-01-14 19:08 [Bug libstdc++/108409] New: std::chrono::current_zone() doesn't work on AIX redi at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-01-15 13:58 ` redi at gcc dot gnu.org
@ 2023-11-06 17:26 ` mac at mcrowe dot com
  6 siblings, 0 replies; 8+ messages in thread
From: mac at mcrowe dot com @ 2023-11-06 17:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

Mike Crowe <mac at mcrowe dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mac at mcrowe dot com

--- Comment #7 from Mike Crowe <mac at mcrowe dot com> ---
ICU tries to solve this problem with a table at
https://github.com/unicode-org/icu/blob/fa6a4661ba002c1c1ee68cbf5c7ac9af75132d07/icu4c/source/common/putil.cpp#L802
and other heuristics in the same file.

Based on my understanding, the table is incorrect for the Australian zones and
US/Aleutian (it gets the short names wrong) and it's missing the non-DST US
zones.

I'm not sure if it's worth going to these lengths to try to map POSIX time zone
strings to Olson names, but I thought I'd provide the link in case it's useful.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-11-06 17:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-14 19:08 [Bug libstdc++/108409] New: std::chrono::current_zone() doesn't work on AIX redi at gcc dot gnu.org
2023-01-14 19:17 ` [Bug libstdc++/108409] " redi at gcc dot gnu.org
2023-01-14 21:59 ` cvs-commit at gcc dot gnu.org
2023-01-14 22:05 ` redi at gcc dot gnu.org
2023-01-15 13:42 ` redi at gcc dot gnu.org
2023-01-15 13:56 ` redi at gcc dot gnu.org
2023-01-15 13:58 ` redi at gcc dot gnu.org
2023-11-06 17:26 ` [Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX or Windows mac at mcrowe dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).