https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124391
--- Comment #2 from Jan Schultke <janschultke at googlemail dot com> ---
I think there's something fishy going on here with excess precision. Despite
the evident rounding to 513.f16, the following assertion fails:
static_assert(512.749999999f16 == 513.f16);
<source>:1:32: error: static assertion failed
1 | static_assert(512.749999999f16 == 513.f16);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~
• the comparison reduces to '(5.1275e+2f == 5.13e+2f)'
I suspect that 512.749999999f16 is internally rounded to 512.75, which is not
actually representable as std::float16_t (it would require one more bit of
precision). When the bit representation of the floating-point literal is
determined, 512.75f is rounded UP to 513.f16.