Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading