llvm / llvm/llvm-project

ICE segfault on `static_assert` and instantiation constrained by concept with lambda NTTPs

Open
#161,467 5 comments 0 reactions 0 assignees View on GitHub
clang:frontend confirmed crash-on-invalid
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

https://godbolt.org/z/YEh68rqea

```cpp
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"

template
using type = T;

template
struct wrap_type {
using type = T;
};

#define MAKE_VALUE(...) ([] { return __VA_ARGS__; })
#define MAKE_TYPE(...) MAKE_VALUE(wrap_type<__VA_ARGS__>())

// #define LIFT_VALUE(...) MAKE_VALUE(__VA_ARGS__<$...>)
#define LIFT_TYPE(...) MAKE_TYPE(__VA_ARGS__<$...>)

#define GET_VALUE(_name, ...) _name.template operator()<__VA_ARGS__>()
#define GET_TYPE(_name, ...) typename decltype(GET_VALUE(_name, __VA_ARGS__))::type

template
concept make_concept = GET_VALUE(pred, GET_TYPE(proj, T), GET_TYPE(proj, Us)...);

constexpr auto is_same = MAKE_VALUE(requires (type)>& f) {
f(wrap_type<$...[1]>());
});

template
requires(sizeof...(Ts) == 1)
using add_cv = volatile const Ts...[0];

static_assert(make_concept);

template>
int x;

int main() {
x;
}
```

```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++26
1. :43:14: current parser token ';'
2. :42:12: parsing function body 'main'
3. :42:12: in compound statement ('{}')
Program terminated with signal: SIGSEGV
Compiler returned: 139
```

Contributor guide

Open the contributing guide

Research direction

Start with the Compiler Explorer reproducer and run the shown clang++ C++26 command to confirm the SIGSEGV during parsing main. Trace the compiler handling of the static_assert and constrained template instantiation involving lambda NTTPs; done means the reproducer no longer crashes and compiles or reports a diagnostic instead.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.