Search code examples
c++c++23stdformat

Why does std::format in LLVM libc++ choke on format strings with ":}>" in them?


The following program does not compile with clang++ -std=c++23 -stdlib=libc++:

// clang++ -std=c++23 -stdlib=libc++ formatbug.cc

#include <format>

int
main(int argc, char **argv)
{
  [[maybe_unused]] auto s = std::format("{0:}>" , argc);
}

The compilation error claims I'm trying to evaluate a consteval function on a non constant expression. You can see the errors here:

https://godbolt.org/z/cv48Kbzjv

Is this just a straight-up bizarre bug in the standard library, or am I triggering some kind of weird digraph/trigraph functionality or advanced formatting feature with the character sequence ":}>"?


Solution

  • This is a bug in libc++ that has already been fixed on Clang trunk for upcoming LLVM 19, presumably with this commit based on a cursory glance at the commit log.