public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types
@ 2024-02-20 19:35 g.peterhoff@t-online.de
  2024-02-20 20:06 ` [Bug libstdc++/114018] " pinskia at gcc dot gnu.org
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: g.peterhoff@t-online.de @ 2024-02-20 19:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

            Bug ID: 114018
           Summary: std::nexttoward is not implemented for C++23-FP-Types
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: g.peterhoff@t-online.de
  Target Milestone: ---

please see https://godbolt.org/z/EoKnEE8eT

thx
Gero

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
@ 2024-02-20 20:06 ` pinskia at gcc dot gnu.org
  2024-02-20 20:07 ` pinskia at gcc dot gnu.org
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-20 20:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This depends on the version of glibc to include the c version of these
functions.  So this is most likely just an artifact of not having a new enough
glibc.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
  2024-02-20 20:06 ` [Bug libstdc++/114018] " pinskia at gcc dot gnu.org
@ 2024-02-20 20:07 ` pinskia at gcc dot gnu.org
  2024-02-20 20:18 ` redi at gcc dot gnu.org
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-20 20:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So if godbolt uses an older version of glibc for x86_64 then report it to them
not us.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
  2024-02-20 20:06 ` [Bug libstdc++/114018] " pinskia at gcc dot gnu.org
  2024-02-20 20:07 ` pinskia at gcc dot gnu.org
@ 2024-02-20 20:18 ` redi at gcc dot gnu.org
  2024-02-20 22:27 ` jsm28 at gcc dot gnu.org
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-20 20:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-02-20
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I don't think that's right, we don't have any std::nexttoward for those types
at all, irrespective of what glibc has. IIRC this was noted as missing when
Jakub implemented the types.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (2 preceding siblings ...)
  2024-02-20 20:18 ` redi at gcc dot gnu.org
@ 2024-02-20 22:27 ` jsm28 at gcc dot gnu.org
  2024-02-20 22:28 ` jakub at gcc dot gnu.org
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2024-02-20 22:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #4 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
I don't know what's expected for C++, but for C, TS 18661-3 and C23 don't have
versions of nexttoward for _FloatN or _FloatNx (recall that the second argument
of nexttoward has type long double independent of the first argument, which is
using long double as a common superset type for all the standard floating types
- but no such common superset type is guaranteed to exist for all the _FloatN
and _FloatNx types, and long double certainly need not be such a type, so
nexttoward doesn't make sense for _FloatN or _FloatNx). Instead, those types
have nextafter, nextup and nextdown functions.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (3 preceding siblings ...)
  2024-02-20 22:27 ` jsm28 at gcc dot gnu.org
@ 2024-02-20 22:28 ` jakub at gcc dot gnu.org
  2024-02-20 22:33 ` pinskia at gcc dot gnu.org
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-20 22:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If you want a function with 2 arguments of the same type, that is
std::nextafter.
In C, nexttoward{f,,l} has first argument of float, double and long double, so
the last one is always long double.
Now, https://eel.is/c++draft/cmath.syn lists
constexpr floating-point-type nextafter(floating-point-type x,
floating-point-type y);
constexpr float nextafterf(float x, float y);
constexpr long double nextafterl(long double x, long double y);
which is correct and
constexpr floating-point-type nexttoward(floating-point-type x, long double y);
constexpr float nexttowardf(float x, long double y);
constexpr long double nexttowardl(long double x, long double y);
which I believe is a bug in the standard, finding next representable number in
direction of long double which might have smaller or uncomparable precision or
range doesn't make much sense.
See
https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602667.html
for more details.  At that point it was
constexpr floating-point-type nexttoward(floating-point-type x,
floating-point-type y);
constexpr float nexttowardf(float x, long double y);
constexpr long double nexttowardl(long double x, long double y);
which was also backwards incompatible change because before the C++23 changes
it was
constexpr double nexttoward(double x, long double y);
constexpr float nexttoward(float x, long double y);
constexpr long double nexttowardl(long double x, long double y);
constexpr float nexttowardf(float x, long double y);
constexpr long double nexttowardl(long double x, long double y);
What is in the standard now looks wrong to me as well, e.g. if long double is
IBM extended format and floating-point-type is std::float128_t, C++23 doesn't
even allow comparison between those two types:
error: invalid operands to binary > (have ‘_Float128’ and ‘long double’)
    4 |   return x > y;
      |          ~~^~~
and very difficult to implement, both because of that because having to handle
all possible long double representations vs. all extended floating point types.
As Joseph said in the above thread, C23 has
_FloatN nextafterfN(_FloatN x, _FloatN y);
_FloatNx nextafterfNx(_FloatNx x, _FloatNx y);
_FloatN nextupfN(_FloatN x);
_FloatNx nextupfNx(_FloatNx x);
_FloatN nextdownfN(_FloatN x);
_FloatNx nextdownfNx(_FloatNx x);
but nexttoward remains double, float and long double only.
Because nexttoward is only meaningful if long double is a superset of the other
floating point type, which is the case for float/double.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (4 preceding siblings ...)
  2024-02-20 22:28 ` jakub at gcc dot gnu.org
@ 2024-02-20 22:33 ` pinskia at gcc dot gnu.org
  2024-02-20 22:37 ` jakub at gcc dot gnu.org
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-20 22:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I know cppreference is not the standard exactly but it does have the following
about nexttoward:
However, an invocation of std::nexttoward is ill-formed if the argument
corresponding to from has extended floating-point type

https://en.cppreference.com/w/cpp/numeric/math/nextafter


So maybe this is invalid after all.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (5 preceding siblings ...)
  2024-02-20 22:33 ` pinskia at gcc dot gnu.org
@ 2024-02-20 22:37 ` jakub at gcc dot gnu.org
  2024-02-20 22:40 ` jakub at gcc dot gnu.org
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-20 22:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Yeah, it is hidden at the end of the page: https://eel.is/c++draft/cmath.syn#4
https://cplusplus.github.io/LWG/issue3790

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (6 preceding siblings ...)
  2024-02-20 22:37 ` jakub at gcc dot gnu.org
@ 2024-02-20 22:40 ` jakub at gcc dot gnu.org
  2024-02-20 22:57 ` jakub at gcc dot gnu.org
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-20 22:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, do we need to define those and std::unreachable (); in their bodies or
something similar?

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (7 preceding siblings ...)
  2024-02-20 22:40 ` jakub at gcc dot gnu.org
@ 2024-02-20 22:57 ` jakub at gcc dot gnu.org
  2024-02-21  0:24 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-20 22:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #8)
> So, do we need to define those and std::unreachable (); in their bodies or
> something similar?

Though, cmath probably can't #include <utility>, so
#ifdef _GLIBCXX_DEBUG
    std::__glibcxx_assert_fail(nullptr, 0, "std::nexttoward with extended
floating point type", nullptr);
#elif defined _GLIBCXX_ASSERTIONS
    __builtin_trap();
#else
    __builtin_unreachable();
#endif
or something similar.
Jon, I can try to write it tomorrow if you tell me what you prefer.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (8 preceding siblings ...)
  2024-02-20 22:57 ` jakub at gcc dot gnu.org
@ 2024-02-21  0:24 ` redi at gcc dot gnu.org
  2024-02-21  7:24 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-21  0:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #8)
> So, do we need to define those and std::unreachable (); in their bodies or
> something similar?

No, it needs to be ill-formed to call them, which is already the case as the
godbolt example in comment 0 shows:

<source>:13:28: error: no matching function for call to 'nexttoward(const T&,
const T&)'

I think there's nothing to do here.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (9 preceding siblings ...)
  2024-02-21  0:24 ` redi at gcc dot gnu.org
@ 2024-02-21  7:24 ` jakub at gcc dot gnu.org
  2024-02-21  8:23 ` de34 at live dot cn
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-21  7:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
But what about following:
#include <cmath>
#include <stdfloat>

auto f = static_cast<std::float128_t (*)(std::float128_t, long
double)>(&std::nexttoward);

This doesn't call std::nexttoward(std::float128_t, long double), just checks if
it is defined.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (10 preceding siblings ...)
  2024-02-21  7:24 ` jakub at gcc dot gnu.org
@ 2024-02-21  8:23 ` de34 at live dot cn
  2024-02-21  8:44 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: de34 at live dot cn @ 2024-02-21  8:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

Jiang An <de34 at live dot cn> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |de34 at live dot cn

--- Comment #12 from Jiang An <de34 at live dot cn> ---
(In reply to Jakub Jelinek from comment #11)
> But what about following:
> #include <cmath>
> #include <stdfloat>
> 
> auto f = static_cast<std::float128_t (*)(std::float128_t, long
> double)>(&std::nexttoward);
> 
> This doesn't call std::nexttoward(std::float128_t, long double), just checks
> if it is defined.

The well-formedness is currently unspecified because std::nexttoward is not
addressable (see [namespace.std]).

I think such conversion should be ill-formed and libstdc++ is currently doing
the right thing. No change needs to be done.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (11 preceding siblings ...)
  2024-02-21  8:23 ` de34 at live dot cn
@ 2024-02-21  8:44 ` jakub at gcc dot gnu.org
  2024-02-21  8:54 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-21  8:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Then I wonder what was the reason for the final LWG3790 revision, the middle
proposed resolution seems to be much more readable and understandable where one
could see exactly what is valid in the synopsis and if the standard attempts to
save lines,
the extra 2 lines in the synopsis are the same size as the extra paragraph
hidden at the end.

Anyway, so INVALID?

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (12 preceding siblings ...)
  2024-02-21  8:44 ` jakub at gcc dot gnu.org
@ 2024-02-21  8:54 ` jakub at gcc dot gnu.org
  2024-02-21 11:55 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-21  8:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, it is described in https://eel.is/c++draft/cmath.syn#2 and probably due to
https://eel.is/c++draft/cmath.syn#3 (so that one can use std::nexttoward(42,
53.0L);
as it has just one floating-point-type argument, there is no template for
promotion
of args for nexttoward).
Perhaps
constexpr standard-floating-point-type nexttoward(standard-floating-point-type
x, long double y);
and define standard-floating-point meaning in [cmath.syn]/2 and talk about it
also in
[cmath.syn]/3?

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (13 preceding siblings ...)
  2024-02-21  8:54 ` jakub at gcc dot gnu.org
@ 2024-02-21 11:55 ` redi at gcc dot gnu.org
  2024-02-21 12:00 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-21 11:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #13)
> Then I wonder what was the reason for the final LWG3790 revision, the middle
> proposed resolution seems to be much more readable and understandable where
> one could see exactly what is valid in the synopsis and if the standard
> attempts to save lines,
> the extra 2 lines in the synopsis are the same size as the extra paragraph
> hidden at the end.

Ah, I've checked the minutes, and the reason for the final form of the wording
is that we wanted to prevent:

std::nexttoward((std::float32_t)0, 0.0L)

With the three overloads for float/double/long double (as implemented in
libstdc++ today) that would be well-formed if float is IEEE binary32. There is
an implicit conversion to float, but that means it returns a float, not a
_Float32 as you would expect it to.

Similarly for nexttoward((std::float64_t)0, 0.0L).

So we do need a change here, because we need to explicitly make that
ill-formed.

Maybe just (with suitable preprocessor checks for the types):

void nexttoward(float32_t, long double) = delete;
void nexttoward(float64_t, long double) = delete;
void nexttoward(float128_t, long double) = delete;

We could also add deleted overloads for bfloat16_t and float16_t although they
don't currently compile anyway, because the float/double/long double overloads
are ambiguous. For consistency in diagnostics, I think defining them all as
deleted would be better.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (14 preceding siblings ...)
  2024-02-21 11:55 ` redi at gcc dot gnu.org
@ 2024-02-21 12:00 ` redi at gcc dot gnu.org
  2024-02-21 12:02 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-21 12:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #16 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We could also just add:

#if __cplusplus > 202002L
  template<floating_point _Tp>
    void
    nexttoward(_Tp, long double) = delete;
#endif


The existing overloads would be preferred for float, double, long double and
integral types, so this would only be chosen for extended floating-point types.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (15 preceding siblings ...)
  2024-02-21 12:00 ` redi at gcc dot gnu.org
@ 2024-02-21 12:02 ` redi at gcc dot gnu.org
  2024-02-21 12:06 ` jakub at gcc dot gnu.org
  2024-02-21 12:12 ` redi at gcc dot gnu.org
  18 siblings, 0 replies; 20+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-21 12:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Or just:

  template<typename _Tp>
    __enable_if_t<is_floating_point<_Tp>::value>
    nexttoward(_Tp, long double) = delete;

So that it is present for C++11 and so works when _Float32 and _Float64 names
are used instead of the C++23 aliases.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (16 preceding siblings ...)
  2024-02-21 12:02 ` redi at gcc dot gnu.org
@ 2024-02-21 12:06 ` jakub at gcc dot gnu.org
  2024-02-21 12:12 ` redi at gcc dot gnu.org
  18 siblings, 0 replies; 20+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-21 12:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #15)
> void nexttoward(float32_t, long double) = delete;
> void nexttoward(float64_t, long double) = delete;
> void nexttoward(float128_t, long double) = delete;
> 
> We could also add deleted overloads for bfloat16_t and float16_t although
> they don't currently compile anyway, because the float/double/long double
> overloads are ambiguous. For consistency in diagnostics, I think defining
> them all as deleted would be better.

The suitable preprocessor conditions could be by placing those declarations
(of course with _Float32, _Float64, _Float128, _Float16 etc., cmath doesn't
rely on stdfloat inclusion) right after the nextafter _Float32 etc. overloads.
Anyway, if your template works properly even for the integers, even better.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Bug libstdc++/114018] std::nexttoward is not implemented for C++23-FP-Types
  2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
                   ` (17 preceding siblings ...)
  2024-02-21 12:06 ` jakub at gcc dot gnu.org
@ 2024-02-21 12:12 ` redi at gcc dot gnu.org
  18 siblings, 0 replies; 20+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-21 12:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114018

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
   Target Milestone|---                         |13.3
           Keywords|                            |accepts-invalid

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-02-21 12:12 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-20 19:35 [Bug libstdc++/114018] New: std::nexttoward is not implemented for C++23-FP-Types g.peterhoff@t-online.de
2024-02-20 20:06 ` [Bug libstdc++/114018] " pinskia at gcc dot gnu.org
2024-02-20 20:07 ` pinskia at gcc dot gnu.org
2024-02-20 20:18 ` redi at gcc dot gnu.org
2024-02-20 22:27 ` jsm28 at gcc dot gnu.org
2024-02-20 22:28 ` jakub at gcc dot gnu.org
2024-02-20 22:33 ` pinskia at gcc dot gnu.org
2024-02-20 22:37 ` jakub at gcc dot gnu.org
2024-02-20 22:40 ` jakub at gcc dot gnu.org
2024-02-20 22:57 ` jakub at gcc dot gnu.org
2024-02-21  0:24 ` redi at gcc dot gnu.org
2024-02-21  7:24 ` jakub at gcc dot gnu.org
2024-02-21  8:23 ` de34 at live dot cn
2024-02-21  8:44 ` jakub at gcc dot gnu.org
2024-02-21  8:54 ` jakub at gcc dot gnu.org
2024-02-21 11:55 ` redi at gcc dot gnu.org
2024-02-21 12:00 ` redi at gcc dot gnu.org
2024-02-21 12:02 ` redi at gcc dot gnu.org
2024-02-21 12:06 ` jakub at gcc dot gnu.org
2024-02-21 12:12 ` redi at gcc dot gnu.org

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).