https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118482

            Bug ID: 118482
           Summary: Mutually dependent decltype ICE
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pashade1 at yahoo dot com
                CC: ewlu at rivosinc dot com
  Target Milestone: ---

GCC encounters an ICE (segfault) when getting the name of the following type
using `typeid()` (see Godbolt link: https://godbolt.org/z/TEaYE7veb, where
clang can compile this).

```
using what_type = decltype(
    [](this auto&& self,
        decltype([](decltype(self)&){}) x = {}){ return x; }());

#include <typeinfo>
auto& info = typeid(what_type);
```

Attempting to use an instance of this type also causes a compiler segfault (see
Godbolt link: https://godbolt.org/z/5x6sn7d8z, where clang also fails to
compile this).

```
using what_type = decltype(
    [](this auto&& self,
        decltype([](decltype(self)&){}) x = {}){ return x; }());

what_type x;

int main() {
    if (x) return 1;
}
```

Both fail for versions 14.1, 14.2, and trunk available on Godbolt. The pattern
requires deducing this (C++23), so these examples are expected to not compile
on any versions older than 14.0.

Reply via email to