public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-11471] libstdc++: Fix std::numeric_limits::lowest() test for strict modes Date: Fri, 23 Jun 2023 16:13:18 +0000 (GMT) [thread overview] Message-ID: <20230623161318.DB8653856DC8@sourceware.org> (raw) https://gcc.gnu.org/g:f11b715ba891ecc936888cc5d4d6a3fab192b5f6 commit r10-11471-gf11b715ba891ecc936888cc5d4d6a3fab192b5f6 Author: Jonathan Wakely <jwakely@redhat.com> 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<T>::is_integer instead of is_integral<T>::value. (cherry picked from commit 45ba5426c129993704a73e6ace4016eaa950d7ee) 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 918a4494d60..33015409365 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 <limits> -#include <type_traits> #include <testsuite_hooks.h> template<typename T> void - do_test(std::true_type) + do_test() { T limits_min = std::numeric_limits<T>::min(); - VERIFY( std::numeric_limits<T>::lowest() == limits_min ); - } - -template<typename T> - void - do_test(std::false_type) - { T limits_max = std::numeric_limits<T>::max(); - VERIFY( std::numeric_limits<T>::lowest() == -limits_max ); + if (std::numeric_limits<T>::is_integer) + VERIFY( std::numeric_limits<T>::lowest() == limits_min ); + else + VERIFY( std::numeric_limits<T>::lowest() == -limits_max ); } -template<typename Tp> - void - do_test() - { do_test<Tp>(typename std::is_integral<Tp>::type()); } - void test01() { do_test<char>();
reply other threads:[~2023-06-23 16:13 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230623161318.DB8653856DC8@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).