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.

Reply via email to