Fix a build failure with Clang 20+ using -std=c++20, where fmt
(v9.1.0, v11.0.0, and possibly other versions) fails to parse
format strings at compile-time in a consteval context. This is
a known issue in fmt, fixed in fmt v11.1.0 (see
https://github.com/fmtlib/fmt/commit/
6797f0c39a4ef13061cbc3bb850c35af7428fdc4).
The following error occurs when building rgw_auth_s3.cc:
src/rgw/rgw_auth_s3.cc:600:22: error: call to consteval function
'fmt::basic_format_string<...>' is not a constant expression
Removing FMT_STRING avoids compile-time format string parsing
and restores buildability across different toolchains.
Test case:
#include <fmt/format.h>
std::string gen_v4_scope(const std::string& region)
{
return fmt::format(FMT_STRING("{:s}"), region);
}
Compile with:
clang -isystem fmt/include -std=c++20 -c test.cc
Signed-off-by: Z. Liu <zhixu.liu@gmail.com>
auto mon = bt.tm_mon + 1;
auto day = bt.tm_mday;
- return fmt::format(FMT_STRING("{:d}{:02d}{:02d}/{:s}/{:s}/aws4_request"),
+ return fmt::format("{:d}{:02d}{:02d}/{:s}/{:s}/aws4_request",
year, mon, day, region, service);
}