Issue 235252
Summary [clang] crashes with SIGSEGV when evaluating __builtin_bit_cast in a static_assert involving a self-referential struct
Labels clang:frontend, crash-on-invalid, generated by fuzzer
Assignees
Reporter k-arrows
    Reproducer:
https://godbolt.org/z/f67G83Mf1
```cpp
template <class To, class From> constexpr To cast(const From &from) {
 __builtin_bit_cast(To, from);
}

struct S {
  S s;
  enum E { e } E;
};

static_assert(cast<S>((char)42).E == S::E::e);
```

Output:
```console
<source>:6:5: error: field has incomplete type 'S'
    6 |   S s;
      |     ^
<source>:5:8: note: definition of 'S' is not complete until the closing '}'
    5 | struct S {
 |        ^
<source>:2:3: warning: _expression_ result unused [-Wunused-value]
    2 |   __builtin_bit_cast(To, from);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:10:15: note: in instantiation of function template specialization 'cast<S, char>' requested here
   10 | static_assert(cast<S>((char)42).E == S::E::e);
      | ^
Program terminated with signal SIGSEGV (11)
Compiler returned: 139
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to