From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 3C3F0385800C; Mon, 11 Oct 2021 19:37:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C3F0385800C MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-4327] libstdc++: Fix std::numeric_limits::lowest() test for strict modes X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 6b6788f8c2748060d922cc22173ff7f8500917e9 X-Git-Newrev: 45ba5426c129993704a73e6ace4016eaa950d7ee Message-Id: <20211011193728.3C3F0385800C@sourceware.org> Date: Mon, 11 Oct 2021 19:37:28 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2021 19:37:28 -0000 https://gcc.gnu.org/g:45ba5426c129993704a73e6ace4016eaa950d7ee commit r12-4327-g45ba5426c129993704a73e6ace4016eaa950d7ee Author: Jonathan Wakely Date: Mon Oct 11 13:28:32 2021 +0100 libstdc++: Fix std::numeric_limits::lowest() test for strict modes This test uses std::is_integral to decide whether we are testing an integral or floating-point type. But that fails for __int128 because is_integral<__int128> is false in strict modes. By using numeric_limits::is_integer instead we get the right answer for all types that have a numeric_limits specialization. We can also simplify the test by removing the unnecessary tag dispatching. libstdc++-v3/ChangeLog: * testsuite/18_support/numeric_limits/lowest.cc: Use numeric_limits::is_integer instead of is_integral::value. Diff: --- .../testsuite/18_support/numeric_limits/lowest.cc | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc b/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc index 54866966ee0..abc967c60f8 100644 --- a/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc +++ b/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc @@ -23,30 +23,20 @@ // 18.2.1.1 template class numeric_limits #include -#include #include template void - do_test(std::true_type) + do_test() { T limits_min = std::numeric_limits::min(); - VERIFY( std::numeric_limits::lowest() == limits_min ); - } - -template - void - do_test(std::false_type) - { T limits_max = std::numeric_limits::max(); - VERIFY( std::numeric_limits::lowest() == -limits_max ); + if (std::numeric_limits::is_integer) + VERIFY( std::numeric_limits::lowest() == limits_min ); + else + VERIFY( std::numeric_limits::lowest() == -limits_max ); } -template - void - do_test() - { do_test(typename std::is_integral::type()); } - void test01() { do_test();