]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
mgr: use constexpr string_view as input to format()
authorCasey Bodley <cbodley@redhat.com>
Mon, 14 Feb 2022 22:58:05 +0000 (17:58 -0500)
committerKefu Chai <tchaikov@gmail.com>
Tue, 22 Mar 2022 15:26:54 +0000 (23:26 +0800)
commitbbb1574eabf0945a626aeeb44ceb3dbb24d4391e
tree60fbcf09edc61c6d84b82a3bed174d6ec9002390
parentfff72cd14c58d06774cbd0274e6144b42448af03
mgr: use constexpr string_view as input to format()

resolves a c++20 compilation error with clang13:

ceph/src/mgr/Mgr.cc:602:42: error: call to consteval function 'fmt::basic_format_string<char, const std::basic_string<char> &>::basic_format_string<const char *, 0>' is not a constant expression
    monc->start_mon_command({fmt::format(cmd, name)}, {},
                                         ^
ceph/src/fmt/include/fmt/core.h:2839:56: note: read of non-constexpr variable 'cmd' is not allowed in a constant expression
  FMT_CONSTEVAL basic_format_string(const S& s) : str_(s) {
                                                       ^
ceph/src/mgr/Mgr.cc:602:42: note: in call to 'basic_format_string(cmd)'
    monc->start_mon_command({fmt::format(cmd, name)}, {},
                                         ^
ceph/src/mgr/Mgr.cc:601:17: note: declared here
    const char* cmd = R"({{"prefix": "mon metadata", "id": "{}"}})";
                ^

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/mgr/Mgr.cc