-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Closed as not planned
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"crashPrefer [crash-on-valid] or [crash-on-invalid]Prefer [crash-on-valid] or [crash-on-invalid]lambdaC++11 lambda expressionsC++11 lambda expressionsobsoleteIssues with old (unsupported) versions of LLVMIssues with old (unsupported) versions of LLVM
Description
The following code causes clang-19 to crash with the error clang++-19: error: clang frontend command failed with exit code 139 (use -v to see invocation)
:
#include <utility>
#include <cstring>
#include <print>
template <typename TypeTuple>
auto count_types() {
return []<size_t... Idx>(std::index_sequence<Idx...>) {
return ([](std::tuple_element_t<Idx, TypeTuple> base) {return base;}(1) + ...);
}(std::make_index_sequence<std::tuple_size_v<TypeTuple>>{});
}
int main() {
std::println("{}", count_types<std::tuple<int>>());
std::println("{}", count_types<std::tuple<int, char>>());
}
Interestingly, if I introduce an additional intermediate lambda to extract Idx, it compiles without error:
#include <utility>
#include <cstring>
#include <print>
template <typename TypeTuple>
auto count_types() {
return []<size_t... Idx>(std::index_sequence<Idx...>) {
return ([]<size_t Index>(std::integral_constant<size_t, Index>) {
return [](std::tuple_element_t<Index, TypeTuple> base) {return base;}(1);
}(std::integral_constant<size_t, Idx>()) + ...);
}(std::make_index_sequence<std::tuple_size_v<TypeTuple>>{});
}
int main() {
std::println("{}", count_types<std::tuple<int>>());
std::println("{}", count_types<std::tuple<int, char>>());
}
Clang-19 from Arch Linux (version 19.1.7 on x86-64) invoked as clang++-19 -emit-llvm -Xclang -disable-llvm-passes --std=c++20 clang_bug.cpp -c -o clang
The same code compiles and runs with the expected result on clang++-20, g++-14 and g++-15
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"crashPrefer [crash-on-valid] or [crash-on-invalid]Prefer [crash-on-valid] or [crash-on-invalid]lambdaC++11 lambda expressionsC++11 lambda expressionsobsoleteIssues with old (unsupported) versions of LLVMIssues with old (unsupported) versions of LLVM