public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107901] New: std::format isn't usable on 16-bit targets Date: Mon, 28 Nov 2022 21:05:07 +0000 [thread overview] Message-ID: <bug-107901-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107901 Bug ID: 107901 Summary: std::format isn't usable on 16-bit targets Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- the std::to_chars overloads for floating-point types are gated on __SIZE_WIDTH__ being at least 32-bits: #if _GLIBCXX_FLOAT_IS_IEEE_BINARY32 && _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 \ && __SIZE_WIDTH__ >= 32 && _GLIBCXX_HOSTED # define __cpp_lib_to_chars 201611L #endif ... #if defined __cpp_lib_to_chars // Floating-point std::to_chars // Overloads for float. to_chars_result to_chars(char* __first, char* __last, float __value) noexcept; to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) noexcept; to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) noexcept; This means that std::format fails to compile on targets with 16-bit size_t, because it assumes that FP types can be printed via std::to_chars: /home/jwakely/src/gcc/build-16bit/msp430-elf/libstdc++-v3/include/format: In instantiation of 'std::__format::_Formatting_scanner<std::__format::_Sink_iter<wchar_t>, wchar_t>::_M_format_arg(std::size_t)::<lambda(auto:42&)> [with auto:42 = float]': /home/jwakely/src/gcc/build-16bit/msp430-elf/libstdc++-v3/include/format:3038:44: required from 'decltype(auto) std::basic_format_arg<_Context>::_M_visit(_Visitor&&, std::__format::_Arg_t) [with _Visitor = std::__format::_Formatting_scanner<std::__format::_Sink_iter<wchar_t>, wchar_t>::_M_format_arg(std::size_t)::<lambda(auto:42&)>; _Context = std::basic_format_context<std::__format::_Sink_iter<wchar_t>, wchar_t>]' /home/jwakely/src/gcc/build-16bit/msp430-elf/libstdc++-v3/include/format:3082:28: required from 'decltype(auto) std::visit_format_arg(_Visitor&&, basic_format_arg<_Context>) [with _Visitor = __format::_Formatting_scanner<__format::_Sink_iter<wchar_t>, wchar_t>::_M_format_arg(std::size_t)::<lambda(auto:42&)>; _Context = basic_format_context<__format::_Sink_iter<wchar_t>, wchar_t>]' /home/jwakely/src/gcc/build-16bit/msp430-elf/libstdc++-v3/include/format:3532:23: required from 'void std::__format::_Formatting_scanner<_Out, _CharT>::_M_format_arg(std::size_t) [with _Out = std::__format::_Sink_iter<wchar_t>; _CharT = wchar_t; std::size_t = unsigned int]' /home/jwakely/src/gcc/build-16bit/msp430-elf/libstdc++-v3/include/format:3527:7: required from here /home/jwakely/src/gcc/build-16bit/msp430-elf/libstdc++-v3/include/format:3546:37: error: static assertion failed 3546 | static_assert(__format::__formattable_with<_Type, _Context>); | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Long term, we want to support std::to_chars everywhere. In the short term, we might want to disable FP types in std::format so that other types can still be formatted.
next reply other threads:[~2022-11-28 21:05 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-28 21:05 redi at gcc dot gnu.org [this message] 2022-11-28 21:11 ` [Bug libstdc++/107901] " redi at gcc dot gnu.org 2022-11-28 21:11 ` redi at gcc dot gnu.org
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: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107901-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe 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).