llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.11k stars 12.01k forks source link

clang miscompilation with consteval functions called implicitly in destructor #109096

Open kelbon opened 1 month ago

kelbon commented 1 month ago

https://godbolt.org/z/MzaPMraqK

This code incorrectly produces runtime error instead of compilation error in checking fmt::format string


#include <fmt/core.h>

template<typename T>
struct scope_exit {
   T val;
constexpr ~scope_exit() {  val(); }
};

int main() {
  scope_exit x([]() { std::string s = fmt::format("{}"); });
}
kelbon commented 1 month ago

https://godbolt.org/z/TTncxY6nP

produces runtime segfault with std::format