On Mon, Sep 07, 2026 at 10:14:39AM +0800, Jakit Liang wrote:
> 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.
>
> For example, when clangd parses and instantiates `_S_to_arg_type` for
> an ordinary `std::format` call, it can produce:
Why would it parse it?
>From what I can see, clang++ doesn't predefine __BFLT16_DIG__ and other
__BFLT16_* macros.
Are you preprocessing with GCC and compiling with clang?
> > > --- a/libstdc++-v3/include/std/format
> > > +++ b/libstdc++-v3/include/std/format
> > > @@ -3373,7 +3373,7 @@ namespace __format
> > > #endif
> > >
> > > #if defined(__BFLT16_DIG__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
> > > - else if constexpr (is_same_v<_Td, decltype(0.0bf16)>)
> > > + else if constexpr (is_same_v<_Td, __gnu_cxx::__bfloat16_t>)
> > > return type_identity<float>();
> > > #endif
Jakub