{"id":2228544,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2228544/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/CAF8dVMUqfv+ggKjr2N=NAefWYgo4BK8Bb=wMS_b5DNqtkmK-Tw@mail.gmail.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<CAF8dVMUqfv+ggKjr2N=NAefWYgo4BK8Bb=wMS_b5DNqtkmK-Tw@mail.gmail.com>","list_archive_url":null,"date":"2026-04-26T23:51:17","name":"[v2,1/5] libstdc++: Fix numeric save offset on Zone lines [PR124851]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"d254f2cba69b28b5ec64431a7cfdabccf8de5476","submitter":{"id":93119,"url":"http://patchwork.ozlabs.org/api/1.2/people/93119/?format=json","name":"Álvaro Begué","email":"alvaro.begue@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/CAF8dVMUqfv+ggKjr2N=NAefWYgo4BK8Bb=wMS_b5DNqtkmK-Tw@mail.gmail.com/mbox/","series":[{"id":501555,"url":"http://patchwork.ozlabs.org/api/1.2/series/501555/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=501555","date":"2026-04-26T23:42:54","name":"libstdc++: chrono tzdb correctness fixes","version":2,"mbox":"http://patchwork.ozlabs.org/series/501555/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2228544/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2228544/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=ioevyv5s;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=ioevyv5s","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","sourceware.org; spf=pass smtp.mailfrom=gmail.com","server2.sourceware.org;\n arc=pass smtp.remote-ip=209.85.217.54"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g3k5m290Kz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 09:52:42 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id D9E794B99F56\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Apr 2026 23:52:40 +0000 (GMT)","from mail-vs1-f54.google.com (mail-vs1-f54.google.com\n [209.85.217.54])\n by sourceware.org (Postfix) with ESMTPS id 13F124BABF16\n for <gcc-patches@gcc.gnu.org>; Sun, 26 Apr 2026 23:51:54 +0000 (GMT)","by mail-vs1-f54.google.com with SMTP id\n ada2fe7eead31-60fbeeeaa7aso5631806137.0\n for <gcc-patches@gcc.gnu.org>; Sun, 26 Apr 2026 16:51:54 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org D9E794B99F56","OpenDKIM Filter v2.11.0 sourceware.org 13F124BABF16"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 13F124BABF16","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 13F124BABF16","ARC-Seal":["i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1777247514; cv=pass;\n b=KIw4FhbqH5ELaw41CbR5KdqIMp7JaGVnyZfNKzb/gjBe82XgxA3nIiZy9bY4HEJLhluU7Nha9pXencSe4CDfeYjblVCXRl1Hv3Jy4OI6QKLKY8QaB1wT8P1Waxj35NEeVLaSNPJWIBCsdKEnieFBxWvmO/XVsArzbt4Jif5sxb4=","i=1; a=rsa-sha256; t=1777247513; cv=none;\n d=google.com; s=arc-20240605;\n b=CGNcYD7cGm1OevPdoUil/M4X9dkgVxhXO1fOF4wd/a82GfbAAGk8QAxh7UcGR/wPCp\n 0Bo095ccHnkBp90aLs19aYPKxS0CHOCA4AuZbLWNItouNw+kx3ZigXJXUNJzHV5qrSc8\n +ngK6rJKnQqW7YjF0JxHcXRPZT5V+M2fhQYzVijaFk0a7LkF2lqeElaQi+cExOpYmtQ4\n aMq/B7kcfcV4mt+bj63qWDUm4lksWSuGukXOPH8IsLYZ7XpsOpEMIwhGdeusMG2b42SN\n 0lL3PR5dAbDoLb+hjDH1WUy1Nh34rRjVckCrFm5C0AGCZ6mCZ7OuOD67FP1fAkQjRPPU\n yR9g=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=sourceware.org; s=key;\n t=1777247514; c=relaxed/simple;\n bh=/JouoRVY01b9oF+jBUJEjpi3v0CESr+LfJhK58SlVmA=;\n h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;\n b=ScSykKO5lUVsAn9cbCvT7fRqjCr5WlEdOCFFtSFQfvmPADlwwyS/pP7FfECyZ9XOztXIgbZXhWy/OC4ggaP04RBIdrBhZc0g5Mo1RAhrN6x/yV6N2uZhUmsnbfmrEEmwHmUmXFE8kmQtFQRdJ4EwjzRcWL06Fk1FCFZemC+hi6c=","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n h=cc:to:subject:message-id:date:from:mime-version:dkim-signature;\n bh=I5S9skDddl6qRZahoYcjePCb9VuyHcxrXruQs1/ZsHs=;\n fh=sWbBxiX87E8F1zPxXVV3X4tQqxV9sZLoQvmjvveliwE=;\n b=Ou51mXBeCrMm0vTHd8jZfM/I1ckNIT/0pIyXy8Q/AA0D7ncMm0XEdKFaql2HBbf1bc\n FxsxC7dpV/cMNWLEtEEt5KBEkcVq08wXy0WwNQyeS3NNbosz5ZgKbWDurqxRFLaj7QRM\n rFmOyZYwjQeCSQQbDnzhZrudrWCFcOpouEQ2gs7xeR0jT9zp373c0F85zU4rLw85uK3f\n U2woAfBdspUlyJs/5zI2pFoURF8zAJ20DHhfsg5UyzLdab+TRUd4DiL95Pu1j+NCer86\n NJ9G0Qhqr6ZyVEcrxLiJsuNT5Coy2VmVoZCcrMfpQXRRDah9LMSS+m0FyF+ze3vyPGMz\n XAAw==; darn=gcc.gnu.org"],"ARC-Authentication-Results":["i=2; server2.sourceware.org","i=1; mx.google.com; arc=none"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1777247513; x=1777852313; darn=gcc.gnu.org;\n h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject\n :date:message-id:reply-to;\n bh=I5S9skDddl6qRZahoYcjePCb9VuyHcxrXruQs1/ZsHs=;\n b=ioevyv5skk3w+ANESW/YqzJVk2En2Sy5d0tHD8zZIo3X87cqqtfzRL3iZBSjEr5wJT\n nyLJP94rNC5d0og5uobCdW4UIoWk4XXTQcOhI0othL/0rs0mJkLVDat6z7iez//cyNcJ\n PJO7tj2GCFHIXKYI7n18Oudpl5i6VKssshENkhBKvIKzaah7nZu742YWtejtAMCBP2FV\n cxNC911XLOiBGYDxepSGzRbbdSnIMjR/ereD6YO2LtEyT9HPppBBlc7eQPkBbpgi06v1\n IseSfWb/DqvQD748kh2MMTT+OSjwdKruGbCPxfE9iwUzuz8AvWLQyhbi7LxkWFjTCK+b\n pYYA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777247513; x=1777852313;\n h=cc:to:subject:message-id:date:from:mime-version:x-gm-gg\n :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n bh=I5S9skDddl6qRZahoYcjePCb9VuyHcxrXruQs1/ZsHs=;\n b=EdxOyl8FTBD9bfyR61z/rThpTcp8Wn7iErvTMmGJND+Ka5ViS132NqmaYoiu1EVJVN\n eTz9Ic6l8zAxZVOL19RqKToMEWUwTwvyAsOhCVXBUZ5K2nxpmsQ0/rLxKbzccY7hipUi\n CdYz92jbmYI5mGHkA6gwexSOUxsVz2I7ETxK3AotD1JQbA3iSpV9LSQkSpTqfsAjAOI9\n E3Omy2pt7bT8gP4eMImTWkeNenJbUk/5Drni150DuXIYRsx+o9mWkvqANBhXnBs6BNzJ\n lXDaQqOv8ZyWZiYwRdJUcz07zu+7IBUnbAYzRcFrjxpT84Zcf3BRCcOkJM0IWpIhAhjg\n cI0w==","X-Gm-Message-State":"AOJu0YxKtfDj1HPb+6wBAIixMlRSAdQXWWrMQODGo13AyDt83I128IwN\n t7WJ11z7qOkD60lst+I0t0PwkxkKZAnC10WgQdLFR+8nJ7tuvXO9nq2Z7EvsU+xTyv66suLFnL0\n 24ARpxgpNkVcOo/SywgHMDdXpOiqU+HaAGA3qvmQ=","X-Gm-Gg":"AeBDiet3k2pt77Is5v+W+ISXs626Wc8TDor02gQkS+INbJvTaR5EHrAXEj3IrEgIqbL\n eh1gqn6ChHnLH/44WkmRhq/G5G0F8Eodlmj7LOuKIuzCR/B9NfTxlqFxkbgLtEUASEb8l+IqBa5\n 5ta1nm8NY4dhC6XifKx9NVTdNUxpZlh8P5GiTTBAVIXXS46jUuKO0Fl0+DHaH3jpM4D3PTy7Jp4\n WOLX6y7k65g21Usp2Ub2CZ7Hjdo/toVYkjzJys5RMRAtTiOXGSfWO9dEjVVvqnxtvJqb9VVo5vL\n bdWqpFr/AOqhs1oyrNGv3PY2+1UYNIr77r18f5Fxu1fTfc/OOkdDLuuNW7c0X8IjcoOF5MFHot7\n R2Ca6z+LwVavrLcuR+UPtNxcoRqYdo8Ytv5gL2pGipQo4O57eEP2kgy5LL8jCxUoGgWmL4Q==","X-Received":"by 2002:a05:6102:8095:b0:605:6b10:f70b with SMTP id\n ada2fe7eead31-616f7a4aa55mr19257501137.30.1777247513323; Sun, 26 Apr 2026\n 16:51:53 -0700 (PDT)","MIME-Version":"1.0","From":"=?utf-8?b?w4FsdmFybyBCZWd1w6k=?= <alvaro.begue@gmail.com>","Date":"Sun, 26 Apr 2026 19:51:17 -0400","X-Gm-Features":"AVHnY4IMsCUp2tP-IzTVON7qfBTKmxb7tLdgXHnEsuMGulPW-T-SQpDKUofCr28","Message-ID":"\n <CAF8dVMUqfv+ggKjr2N=NAefWYgo4BK8Bb=wMS_b5DNqtkmK-Tw@mail.gmail.com>","Subject":"[PATCH v2 1/5] libstdc++: Fix numeric save offset on Zone lines\n [PR124851]","To":"gcc-patches@gcc.gnu.org","Cc":"jwakely@redhat.com, libstdc++@gcc.gnu.org, tkaminsk@redhat.com,\n\t=?utf-8?b?w4FsdmFybyBCZWd1w6k=?= <alvaro.begue@gmail.com>","Content-Type":"multipart/alternative; boundary=\"000000000000b5abcc065065aedc\"","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"When a Zone line specifies a numeric value as its RULES field (the\nconstant DST save value for that zone line, e.g. Africa/Gaborone's\n\"2 1 CAST\" line), the parser stored the standard offset alone in\nZoneInfo::m_offset. ZoneInfo::to() then returned that as\nsys_info::offset, dropping the numeric save and reporting a total\noffset that was wrong by the save amount.\n\nThis was inconsistent with the two ZoneInfo constructors that take a\nsys_info, which previously stored the *total* offset (stdoff + save) in\nm_offset. As a result m_offset's semantics depended on which code path\ncreated the ZoneInfo, and only the parser path's lines with non-zero\nnumeric save were observably broken.\n\nFix by giving m_offset a single semantics: always the standard offset\nonly. The two sys_info-taking constructors now subtract the save before\nstoring, and to() adds it back when reconstructing the sys_info.\n\nThe remaining .offset() callers inside _M_get_sys_info already expect\nthe standard offset (they are computing rule firing times, where the\nsave component is added separately from the active rule's save value),\nso no other call sites need adjustment.\n\nlibstdc++-v3/ChangeLog:\n\nPR libstdc++/124851\n* src/c++20/tzdb.cc (ZoneInfo::ZoneInfo(sys_info&&)): Store\nstdoff only in m_offset (subtract info.save).\n(ZoneInfo::ZoneInfo(const pair<sys_info, string_view>&)):\nLikewise.\n(ZoneInfo::offset()): Document new semantics.\n(ZoneInfo::to(sys_info&)): Add m_save back to offset() when\npopulating sys_info::offset.\n* testsuite/std/time/time_zone/numeric_save.cc: New test.\n\nSigned-off-by: Álvaro Begué <alvaro.begue@gmail.com>\n---\n libstdc++-v3/src/c++20/tzdb.cc                |  9 +--\n .../std/time/time_zone/numeric_save.cc        | 58 +++++++++++++++++++\n 2 files changed, 63 insertions(+), 4 deletions(-)\n create mode 100644\nlibstdc++-v3/testsuite/std/time/time_zone/numeric_save.cc","diff":"diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc\nindex b0fbfc46a..1e49bb749 100644\n--- a/libstdc++-v3/src/c++20/tzdb.cc\n+++ b/libstdc++-v3/src/c++20/tzdb.cc\n@@ -478,11 +478,12 @@ namespace std::chrono\n\n       ZoneInfo(sys_info&& info)\n       : m_buf(std::move(info.abbrev)), m_expanded(true), m_save(info.save),\n- m_offset(info.offset), m_until(info.end)\n+ m_offset(info.offset - seconds(info.save)), m_until(info.end)\n       { }\n\n       ZoneInfo(const pair<sys_info, string_view>& info)\n-      : m_expanded(true), m_save(info.first.save),\nm_offset(info.first.offset),\n+      : m_expanded(true), m_save(info.first.save),\n+ m_offset(info.first.offset - seconds(info.first.save)),\n  m_until(info.first.end)\n       {\n  if (info.second.size())\n@@ -494,7 +495,7 @@ namespace std::chrono\n  m_buf += info.first.abbrev;\n       }\n\n-      // STDOFF: Seconds from UTC during standard time.\n+      // STDOFF: Seconds from UTC during standard time (without any save).\n       seconds\n       offset() const noexcept { return m_offset; }\n\n@@ -539,7 +540,7 @@ namespace std::chrono\n   return false;\n\n  info.end = until();\n- info.offset = offset();\n+ info.offset = offset() + seconds(m_save);\n  info.save = minutes(m_save);\n  info.abbrev = format();\n  format_abbrev_str(info); // expand %z\ndiff --git a/libstdc++-v3/testsuite/std/time/time_zone/numeric_save.cc\nb/libstdc++-v3/testsuite/std/time/time_zone/numeric_save.cc\nnew file mode 100644\nindex 000000000..1b5b22263\n--- /dev/null\n+++ b/libstdc++-v3/testsuite/std/time/time_zone/numeric_save.cc\n@@ -0,0 +1,58 @@\n+// { dg-do run { target c++20 } }\n+// { dg-require-effective-target tzdb }\n+// { dg-require-effective-target cxx11_abi }\n+// { dg-xfail-run-if \"no weak override on AIX\" { powerpc-ibm-aix* } }\n+\n+// When a Zone line specifies a numeric value as its RULES field, that\n+// value is the constant DST save value for that zone line.  Per\n+// [time.zone.info.sys] sys_info::offset is the total UTC offset\n+// (stdoff + save).\n+\n+#include <chrono>\n+#include <fstream>\n+#include <testsuite_hooks.h>\n+\n+static bool override_used = false;\n+\n+namespace __gnu_cxx\n+{\n+  const char* zoneinfo_dir_override() {\n+    override_used = true;\n+    return \"./\";\n+  }\n+}\n+\n+int\n+main()\n+{\n+  using namespace std::chrono;\n+\n+  std::ofstream(\"tzdata.zi\") << R\"(# version test_numeric_save\n+Z Test/Gaborone 2 -  CAT  1943 Sep 19 2\n+                2 1  CAST 1944 Mar 19 2\n+                2 -  CAT\n+)\";\n+\n+  const auto& db = reload_tzdb();\n+  VERIFY( override_used );\n+  VERIFY( db.version == \"test_numeric_save\" );\n+\n+  auto* tz = locate_zone(\"Test/Gaborone\");\n+\n+  // Sample well inside the CAST (numeric-save) zone line.\n+  auto info = tz->get_info(sys_days(1943y/December/15));\n+  VERIFY( info.offset == 3h );        // stdoff +2h + save +1h\n+  VERIFY( info.save == 60min );\n+  VERIFY( info.abbrev == \"CAST\" );\n+\n+  // Bordering zone lines should report the standard offset with save 0.\n+  auto before = tz->get_info(sys_days(1943y/September/1));\n+  VERIFY( before.offset == 2h );\n+  VERIFY( before.save == 0min );\n+  VERIFY( before.abbrev == \"CAT\" );\n+\n+  auto after = tz->get_info(sys_days(1944y/April/15));\n+  VERIFY( after.offset == 2h );\n+  VERIFY( after.save == 0min );\n+  VERIFY( after.abbrev == \"CAT\" );\n+}\n","prefixes":["v2","1/5"]}