Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ":}>"?

like image 505
user3188445 Avatar asked Oct 28 '25 02:10

user3188445


1 Answers

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.

like image 196
user17732522 Avatar answered Oct 30 '25 16:10

user17732522