public inbox for
 help / color / mirror / Atom feed
From: Jonathan Wakely <>
Subject: [committed] libstdc++: Fix -Wunused-local-typedefs warning in <compare>
Date: Fri, 4 Mar 2022 11:30:56 +0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

[-- Attachment #1: Type: text/plain, Size: 1507 bytes --]

On 03/03/22 22:38 +0000, Jonathan Wakely wrote:
>Tested x86_64-linux (-m32/-m64), powerpc64-linux (-m32/-m64),
>powerpc64le-linux, powerpc-aix (maix32/-maix64/-mlong-double-128).
>Pushed to trunk. I'm inclined to backport this to gcc-11 after some soak
>time on trunk (but not gcc-10, because it needs __builtin_bit_cast).
>-- >8 --
>This removes a FIXME in <compare>, defining the total order for
>floating-point types. I originally opened PR96526 to request a new
>compiler built-in to implement this, but now that we have std::bit_cast
>it can be done entirely in the library.
>The implementation is based on the glibc definitions of totalorder,
>totalorderf, totalorderl etc.
>I think this works for all the types that satisfy std::floating_point
>today, and should also work for the types expected to be added by P1467
>except for std::bfloat16_t. It also supports some additional types that
>don't currently satisfy std::floating_point, such as __float80, but we
>probably do want that to satisfy the concept for non-strict modes.
>	PR libstdc++/96526
>	* libsupc++/compare (strong_order): Add missing support for
>	floating-point types.
>	* testsuite/18_support/comparisons/algorithms/
>	New test.

That commit produces a warning due to a typedef that is only needed
for some targets, which caused:

FAIL: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++20 (test for excess errors)

Here's the fix. Tested x86_64-linux, pushed to trunk.

[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1134 bytes --]

commit 289f65d643e18210433e0f08ccaaf5b08b3d6f39
Author: Jonathan Wakely <>
Date:   Fri Mar 4 10:43:29 2022

    libstdc++: Fix -Wunused-local-typedefs warning in <compare>
            * libsupc++/compare (strong_order::_S_fp_cmp): Move typedef
            inside #if condition.

diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare
index a8747207b23..050cf7ed20d 100644
--- a/libstdc++-v3/libsupc++/compare
+++ b/libstdc++-v3/libsupc++/compare
@@ -850,8 +850,6 @@ namespace std
 	    return strong_ordering::equal; // All bits are equal, we're done.
 	  using enum _Fp_fmt;
-	  using _Int = decltype(__ix);
 	  constexpr auto __fmt = _S_fp_fmt<_Tp>();
 	  if constexpr (__fmt == _Dbldbl) // double-double
@@ -899,6 +897,8 @@ namespace std
 		  // bit to be reversed. Flip that to give desired ordering.
 		  if (__builtin_isnan(__x) && __builtin_isnan(__y))
+		      using _Int = decltype(__ix);
 		      constexpr int __nantype = __fmt == _Binary32  ?  22
 					      : __fmt == _Binary64  ?  51
 					      : __fmt == _Binary128 ? 111

      reply	other threads:[~2022-03-04 11:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 22:38 [committed] libstdc++: Implement std::strong_order for floating-point types [PR96526] Jonathan Wakely
2022-03-04 11:30 ` Jonathan Wakely [this message]

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be 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).