diff options
author | Tomasz Kamiński <tkaminsk@redhat.com> | 2025-03-11 11:59:36 +0100 |
---|---|---|
committer | Tomasz Kamiński <tkaminsk@redhat.com> | 2025-03-12 13:09:20 +0100 |
commit | 445128c12cf22081223f7385196ee3889ef4c4b2 (patch) | |
tree | 6723bef366fa29186d753ccd8c216af11bfc8e69 /gcc/fortran/array.cc | |
parent | 2ac842a1e82efc6e4e4d21f880c9888c523788e7 (diff) | |
download | gcc-445128c12cf22081223f7385196ee3889ef4c4b2.zip gcc-445128c12cf22081223f7385196ee3889ef4c4b2.tar.gz gcc-445128c12cf22081223f7385196ee3889ef4c4b2.tar.bz2 |
libstdc++: Correct preprocessing checks for floatX_t and bfloat_16 formatting
Floating points types _Float16, _Float32, _Float64, and bfloat16,
can be formatted only if std::to_chars overloads for such types
were provided. Currently this is only the case for architectures
where float and double are 32-bits and 64-bits IEEE floating points types.
This patch updates the preprocessing checks for formatters
for above types to check _GLIBCXX_FLOAT_IS_IEEE_BINARY32
and _GLIBCXX_DOUBLE_IS_IEEE_BINARY64. Making them non-formattable
on non-IEEE architectures.
Remove a potential UB, where we could produce basic_format_arg
with _M_type set to _Arg_fp32 or _Arg_fp64, that was later not
handled by `_M_visit`.
libstdc++-v3/ChangeLog:
* include/std/format (formatter<_Float16, _CharT>): Define only if
_GLIBCXX_FLOAT_IS_IEEE_BINARY32 macro is defined.
(formatter<_Float16, _CharT>): As above.
(formatter<__gnu_cxx::__bfloat16_t, _CharT>): As above.
(formatter<_Float64, _CharT>): Define only if
_GLIBCXX_DOUBLE_IS_IEEE_BINARY64 is defined.
(basic_format_arg::_S_to_arg_type): Normalize _Float32 and _Float64
only to float and double respectivelly.
(basic_format_arg::_S_to_enum): Remove handling of _Float32 and _Float64.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Diffstat (limited to 'gcc/fortran/array.cc')
0 files changed, 0 insertions, 0 deletions