From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by sourceware.org (Postfix) with ESMTPS id 77E5D3858039; Sat, 27 Feb 2021 11:42:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 77E5D3858039 From: Hans-Peter Nilsson To: , , Subject: [PATCH/RFA] libstdc++: provide conversion from day, month to unsigned long, PR99301 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT Message-ID: <20210227114206.C3F46203B5@pchp3.se.axis.com> Date: Sat, 27 Feb 2021 12:42:06 +0100 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Feb 2021 11:42:10 -0000 Since 97d6161f6a7fa712 / r11-7370 "libstdc++: More efficient days from date" I see an additional 81 testsuite-errors for cris-elf, with this in g++.log for one randomly picked regressing test: FAIL: g++.dg/cpp1y/pr57640.C -std=c++2a (test for excess errors) Excess errors: /x/gccobj/cris-elf/libstdc++-v3/include/chrono:2483:25: error: invalid 'static_cast' from type 'const std::chrono::month' to type 'uint32_t' {aka 'long unsigned int'} /x/gccobj/cris-elf/libstdc++-v3/include/chrono:2484:25: error: invalid 'static_cast' from type 'const std::chrono::day' to type 'uint32_t' {aka 'long unsigned int'} /x/gccobj/cris-elf/libstdc++-v3/include/chrono:2496:69: error: no matching function for call to 'std::chrono::duration >::duration()' The commit shows conversions to uint32_t, which for e.g. x86_64-linux is "unsigned int", and there are explicit conversions to unsigned int for month and day (see patch context). But, "newlib ILP32 targets" have an uint32_t that is effectively typedef'd "long unsigned int" (see newlib-stdint.h UINT32_TYPE). Better provide an unsigned long conversion aside the unsigned ones. Tested cris-elf. Pending x86_64-linux regtest results, ok? libstdc++-v3: PR libstdc++/99301 * include/std/chrono (day, month): Provide conversion to unsigned long. --- libstdc++-v3/include/std/chrono | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index fcdaee7328ed..33fb0860b41a 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -1334,6 +1334,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION operator unsigned() const noexcept { return _M_d; } + constexpr explicit + operator unsigned long() const noexcept + { return _M_d; } + constexpr bool ok() const noexcept { return 1 <= _M_d && _M_d <= 31; } @@ -1443,6 +1447,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION operator unsigned() const noexcept { return _M_m; } + explicit constexpr + operator unsigned long() const noexcept + { return _M_m; } + constexpr bool ok() const noexcept { return 1 <= _M_m && _M_m <= 12; } -- 2.11.0