[Clang++] Crash Report
I was trying to compile my decorator.cpp when clang++ crashed.
$ clang++ -std=c++23 ./decorator.cpp
clang++: error: unable to execute command: Illegal instruction: 4
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Homebrew clang version 22.1.1
Target: arm64-apple-darwin25.3.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/22.1.1/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin25.cfg
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /var/folders/rr/3_9jzgyd7vv9p2q_1ckmy7jw0000gn/T/decorator-26abb7.cpp
clang++: note: diagnostic msg: /var/folders/rr/3_9jzgyd7vv9p2q_1ckmy7jw0000gn/T/decorator-26abb7.sh
clang++: note: diagnostic msg: Crash backtrace is located in
clang++: note: diagnostic msg: /Users/*******/Library/Logs/DiagnosticReports/clang-22_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang++: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang++: note: diagnostic msg:
********************
The source file content is shown below. Lines start with // ! is where caused this crash (I think).
// assume some callable f
// we want to add logic to f in a Python scheme `@decorator`
// `auto decorated = Decorated<decorator>(f)` or `decorator(f)`
// a decorator that time decorated function
#include <chrono>
#include <concepts>
#include <print>
#include <type_traits>
#include <utility>
auto timed = [](auto && f) {
// ! v Here, if rename captured variable `f` to any other name, the crash will not happen
return [f = std::forward<decltype(f)>(f)]<typename... Args>(
Args &&... args) -> std::invoke_result_t<decltype(f), Args &&...>
requires std::invocable<decltype(f), Args &&...>
{
if constexpr (std::is_void_v<std::invoke_result_t<decltype(f), Args &&...>>) {
auto start = std::chrono::steady_clock::now();
std::invoke(f, std::forward<Args>(args)...);
auto end = std::chrono::steady_clock::now();
std::println(stdout, "runtime: {}", end - start);
return;
}
else {
auto start = std::chrono::steady_clock::now();
decltype(auto) ret = std::invoke(f, std::forward<Args>(args)...);
auto end = std::chrono::steady_clock::now();
std::println(stdout, "runtime: {}", end - start);
return ret;
}
};
};
using namespace std::chrono_literals;
class Foo {
public:
void test() const & { std::println(stdout, "call void Foo::test() const &;"); }
void test() & { std::println(stdout, "call void Foo::test() &;"); }
void test() && { std::println(stdout, "call void Foo::test() &&;"); }
};
// void f(Foo bar) { bar.test(); }
// void f(const Foo & bar) { bar.test(); }
// void f(Foo && bar) { std::move(bar).test(); }
void f(Foo bar) { bar.test(); }
int main() {
const Foo bar1;
Foo bar2;
auto timed_f = timed(f);
timed_f(bar1);
timed_f(bar2);
timed_f(Foo{});
// ! v However this is OK
auto ff = [bar2 = std::forward<Foo>(bar2)] (){};
}
Required files are attached except /Users/*******/Library/Logs/DiagnosticReports/clang-22_<YYYY-MM-DD-HHMMSS>_<hostname>.crash not found. In the folder I find clang-22-2026-05-16-231352.ips and no *.crash file. Since the .ips is not supported by GitHub file uploading, it is renamed as .txt and uploaded.
decorator-3c6a2a.cpp decorator-3c6a2a.sh clang-22-2026-05-16-231352.txt
Looks like #194068 fixed this. Could you try the latest trunk?
Oh, the armv8-a clang (trunk) in Compiler Explorer can compile. Sorry for not trying before creating issue. 😭😭
@llvm/issue-subscribers-clang-frontend
Author: NYA (ConnectionFailedd)
$ clang++ -std=c++23 ./decorator.cpp
clang++: error: unable to execute command: Illegal instruction: 4
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Homebrew clang version 22.1.1
Target: arm64-apple-darwin25.3.0
Thread model: posix
InstalledDir: /opt/homebrew/Cellar/llvm/22.1.1/bin
Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin25.cfg
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /var/folders/rr/3_9jzgyd7vv9p2q_1ckmy7jw0000gn/T/decorator-26abb7.cpp
clang++: note: diagnostic msg: /var/folders/rr/3_9jzgyd7vv9p2q_1ckmy7jw0000gn/T/decorator-26abb7.sh
clang++: note: diagnostic msg: Crash backtrace is located in
clang++: note: diagnostic msg: /Users/*******/Library/Logs/DiagnosticReports/clang-22_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang++: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang++: note: diagnostic msg:
********************
The source file content is shown below. Lines start with // ! is where caused this crash (I think).
// assume some callable f
// we want to add logic to f in a Python scheme `@<!-- -->decorator`
// `auto decorated = Decorated<decorator>(f)` or `decorator(f)`
// a decorator that time decorated function
#include <chrono>
#include <concepts>
#include <print>
#include <type_traits>
#include <utility>
auto timed = [](auto && f) {
// ! v Here, if rename captured variable `f` to any other name, the crash will not happen
return [f = std::forward<decltype(f)>(f)]<typename... Args>(
Args &&... args) -> std::invoke_result_t<decltype(f), Args &&...>
requires std::invocable<decltype(f), Args &&...>
{
if constexpr (std::is_void_v<std::invoke_result_t<decltype(f), Args &&...>>) {
auto start = std::chrono::steady_clock::now();
std::invoke(f, std::forward<Args>(args)...);
auto end = std::chrono::steady_clock::now();
std::println(stdout, "runtime: {}", end - start);
return;
}
else {
auto start = std::chrono::steady_clock::now();
decltype(auto) ret = std::invoke(f, std::forward<Args>(args)...);
auto end = std::chrono::steady_clock::now();
std::println(stdout, "runtime: {}", end - start);
return ret;
}
};
};
using namespace std::chrono_literals;
class Foo {
public:
void test() const & { std::println(stdout, "call void Foo::test() const &;"); }
void test() & { std::println(stdout, "call void Foo::test() &;"); }
void test() && { std::println(stdout, "call void Foo::test() &&;"); }
};
// void f(Foo bar) { bar.test(); }
// void f(const Foo & bar) { bar.test(); }
// void f(Foo && bar) { std::move(bar).test(); }
void f(Foo bar) { bar.test(); }
int main() {
const Foo bar1;
Foo bar2;
auto timed_f = timed(f);
timed_f(bar1);
timed_f(bar2);
timed_f(Foo{});
// ! v However this is OK
auto ff = [bar2 = std::forward<Foo>(bar2)] (){};
}
Required files are attached except /Users/*******/Library/Logs/DiagnosticReports/clang-22_<YYYY-MM-DD-HHMMSS>_<hostname>.crash not found. In the folder I find clang-22-2026-05-16-231352.ips and no *.crash file. Since the .ips is not supported by GitHub file uploading, it is renamed as .txt and uploaded.
decorator-3c6a2a.cpp decorator-3c6a2a.sh clang-22-2026-05-16-231352.txt