fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
19.83k stars 2.42k forks source link

Error when formatting `_BitInt` #4007

Open canhld94 opened 3 weeks ago

canhld94 commented 3 weeks ago

It's good in version 9.1.0 (https://godbolt.org/z/e5rzjxbEb), but starts failing since v10 (https://godbolt.org/z/fEdsc75rb):

/opt/compiler-explorer/libs/fmt/10.2.1/include/fmt/core.h:1828:39: error: constexpr variable 'desc' must be initialized by a constant expression
 1828 |   static constexpr unsigned long long desc =
      |                                       ^
 1829 |       (is_packed ? detail::encode_types<Context, Args...>()
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1830 |                  : detail::is_unpacked_bit | num_args) |
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1831 |       (num_named_args != 0
      |       ~~~~~~~~~~~~~~~~~~~~
 1832 |            ? static_cast<unsigned long long>(detail::has_named_args_bit)
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1833 |            : 0);
vitaut commented 3 weeks ago

I was not aware of _BitInt working in version 9, it was entirely accidental. We should make it work intentionally and add a test case.