You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
regression in 'constexpr' expansion of 'fmt::v8::basic_format_string...'Β #2898
@vitaut I understand the compile-time format evaluation/validateion.
I believe the above issue is slightly different w.r.t. that both the format and arguments are constant and could be evaluated during compile time (ie. effectively constexpr) but because the fmt is passed as a function parameter it is not detected as strictly constexpr.
Isn't there a way to have a fall-back in case the strict compile-time evaluation fails. In the example above, the function err_format cannot be constexpr because std::string does not allow constexpr allocation/initialisation across function boundaries.
Is the behaviour you quoted compatible with the defined behaviour for std::format(...)?
Activity
vitaut commentedon May 17, 2022
{fmt} 8.x requires format strings to be known at compile time by default. Quoting release notes:
Enabled compile-time format string check by default. For example (godbolt):
gives a compile-time error on compilers with C++20
constevalsupport (gcc 10+, clang 11+) becausedis not a valid format specifier for a string.To pass a runtime string wrap it in
fmt::runtime:RalphSteinhagen commentedon May 19, 2022
@vitaut I understand the compile-time format evaluation/validateion.
I believe the above issue is slightly different w.r.t. that both the format and arguments are constant and could be evaluated during compile time (ie. effectively
constexpr) but because thefmtis passed as a function parameter it is not detected as strictlyconstexpr.Isn't there a way to have a fall-back in case the strict compile-time evaluation fails. In the example above, the function
err_formatcannot beconstexprbecausestd::stringdoes not allow constexpr allocation/initialisation across function boundaries.Is the behaviour you quoted compatible with the defined behaviour for
std::format(...)?vitaut commentedon May 19, 2022
To make this work (with or without
strict) you'll need to pass the format string asfmt::format_string:Yes.
RalphSteinhagen commentedon May 19, 2022
@vitaut thanks for the help and work-arounds! Much appreciated! π