On Mon, 7 Sept 2026 at 03:14, Jakit Liang <[email protected]> wrote: > > Hi Jonathan, > > Thanks for the review. > > There is nothing inherently wrong with the `0.0bf16` literal when > compiled by GCC. The issue is that it is only used here to obtain the > bfloat16 type, but exposing this GCC-specific literal in the libstdc++ > header causes problems for Clang-based tooling such as clangd.
This information needs to be in the commit message. > > For example, when clangd parses and instantiates `_S_to_arg_type` for > an ordinary `std::format` call, it can produce: > > ``` > 'auto' in return type deduced as > 'type_identity<const char *>' > but deduced as 'type_identity<float>' in an earlier return statement > ``` > > GCC itself compiles the code correctly. Using > `__gnu_cxx::__bfloat16_t` directly expresses the same type check > without requiring the parser to handle the bf16 literal, so the > bfloat16-to-float normalization is unchanged. How does clangd handle the definition of the __bfloat16_t typedef, which uses the literal? > > I think this is useful on the gcc-14 release branch because GCC 14's > libstdc++ headers are consumed by Clang/clangd tooling, and this > results in diagnostics for otherwise valid `std::format` code. The > change is limited to the internal type check and does not change ABI > or runtime behaviour. > > I'll also avoid sending a `[PATCH 0/1]` cover letter for a single > patch and put the explanation in the commit message. > > Thanks, > Jakit
