public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug libstdc++/114770] New: std::chrono::locate_zone("Asia/Chungking") fails on Debian Sid @ 2024-04-18 14:55 redi at gcc dot gnu.org 2024-04-18 16:32 ` [Bug libstdc++/114770] " redi at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: redi at gcc dot gnu.org @ 2024-04-18 14:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114770 Bug ID: 114770 Summary: std::chrono::locate_zone("Asia/Chungking") fails on Debian Sid Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- #include <chrono> int main() { (void) std::chrono::locate_zone("Asia/Chungking"); } With the latest tzdata (version 2024a-2) on Debian Sid this fails: terminate called after throwing an instance of 'std::runtime_error' what(): tzdb: cannot locate zone: Asia/Chungking Aborted (core dumped) The problem is a Debian patch that enables link chaining, so that one link can have another link as its target: https://sources.debian.org/patches/tzdata/2024a-2/ziguard.awk-Move-link-to-link-feature-from-vanguard-to-ma.patch/ This feature was added to tzdata in 2022, but isn't compatible with the expectations of the C++20 standard. When chrono::locate_zone finds a link, it expects its target to be a zone, not another link. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/114770] std::chrono::locate_zone("Asia/Chungking") fails on Debian Sid 2024-04-18 14:55 [Bug libstdc++/114770] New: std::chrono::locate_zone("Asia/Chungking") fails on Debian Sid redi at gcc dot gnu.org @ 2024-04-18 16:32 ` redi at gcc dot gnu.org 2024-04-19 20:06 ` cvs-commit at gcc dot gnu.org 2024-05-21 9:20 ` jakub at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: redi at gcc dot gnu.org @ 2024-04-18 16:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114770 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 Last reconfirmed| |2024-04-18 Target Milestone|--- |13.3 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/114770] std::chrono::locate_zone("Asia/Chungking") fails on Debian Sid 2024-04-18 14:55 [Bug libstdc++/114770] New: std::chrono::locate_zone("Asia/Chungking") fails on Debian Sid redi at gcc dot gnu.org 2024-04-18 16:32 ` [Bug libstdc++/114770] " redi at gcc dot gnu.org @ 2024-04-19 20:06 ` cvs-commit at gcc dot gnu.org 2024-05-21 9:20 ` jakub at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2024-04-19 20:06 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114770 --- Comment #1 from GCC 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:eed7fb1b2fe72150cd6af10dd3b8f7fc4f0a4da1 commit r14-10043-geed7fb1b2fe72150cd6af10dd3b8f7fc4f0a4da1 Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Apr 18 12:14:41 2024 +0100 libstdc++: Support link chains in std::chrono::tzdb::locate_zone [PR114770] Since 2022 the TZif format defined in the zic(8) man page has said that links can refer to other links, rather than only referring to a zone. This isn't supported by the C++20 spec, which assumes that the target() for a chrono::time_zone_link always names a chrono::time_zone, not another chrono::time_zone_link. This hasn't been a problem until now, because there are no entries in the tzdata file that chain links together. However, Debian Sid has changed the target of the Asia/Chungking link from the Asia/Shanghai zone to the Asia/Chongqing link, creating a link chain. The libstdc++ code is unable to handle this, so chrono::locate_zone("Asia/Chungking") will fail with the tzdata.zi file from Debian Sid. It seems likely that the C++ spec will need a change to allow link chains, so that the original structure of the IANA database can be fully represented by chrono::tzdb. The alternative would be for chrono::tzdb to flatten all chains when loading the data, so that a link's target is always a zone, but this means throwing away information present in the tzdata.zi input file. In anticipation of a change to the spec, this commit adds support for chained links to libstdc++. When a name is found to be a link, we try to find its target in the list of zones as before, but now if the target isn't the name of a zone we don't fail. Instead we look for another link with that name, and keep doing that until we reach the end of the chain of links, and then look up the last target as a zone. This new logic would get stuck in a loop if the tzdata.zi file is buggy and defines a link chain that contains a cycle, e.g. two links that refer to each other. To deal with that unlikely case, we use the tortoise and hare algorithm to detect cycles in link chains, and throw an exception if we detect a cycle. Cycles in links should never happen, and it is expected that link chains will be short (if they occur at all) and so the code is optimized for short chains without cycles. Longer chains (four or more links) and cycles will do more work, but won't fail to resolve a chain or get stuck in a loop. The new test file checks various forms of broken links and cycles. Also add a new check in the testsuite that every element in the get_tzdb().zones and get_tzdb().links sequences can be successfully found using locate_zone. libstdc++-v3/ChangeLog: PR libstdc++/114770 * src/c++20/tzdb.cc (do_locate_zone): Support links that have another link as their target. * testsuite/std/time/tzdb/1.cc: Check that all zones and links can be found by locate_zone. * testsuite/std/time/tzdb/links.cc: New test. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/114770] std::chrono::locate_zone("Asia/Chungking") fails on Debian Sid 2024-04-18 14:55 [Bug libstdc++/114770] New: std::chrono::locate_zone("Asia/Chungking") fails on Debian Sid redi at gcc dot gnu.org 2024-04-18 16:32 ` [Bug libstdc++/114770] " redi at gcc dot gnu.org 2024-04-19 20:06 ` cvs-commit at gcc dot gnu.org @ 2024-05-21 9:20 ` jakub at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: jakub at gcc dot gnu.org @ 2024-05-21 9:20 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114770 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|13.3 |13.4 --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- GCC 13.3 is being released, retargeting bugs to GCC 13.4. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-21 9:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-04-18 14:55 [Bug libstdc++/114770] New: std::chrono::locate_zone("Asia/Chungking") fails on Debian Sid redi at gcc dot gnu.org 2024-04-18 16:32 ` [Bug libstdc++/114770] " redi at gcc dot gnu.org 2024-04-19 20:06 ` cvs-commit at gcc dot gnu.org 2024-05-21 9:20 ` jakub at gcc dot gnu.org
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).