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

            Bug ID: 122548
           Summary: ICE on defining local class in global scope
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program
```
auto f() {
    struct A { struct B; };
    return (A*)nullptr;
}

template<class T> struct remove_reference { typedef T type; };
template<class T> struct remove_reference<T&> { typedef T type; };

using A = remove_reference<decltype(*f())>::type;

struct A::B {};
```

is accepted by Clang and MSVC, but it crashes GCC:

<source>:11:14: internal compiler error: in poplevel_class, at
cp/name-lookup.cc:5696
   11 | struct A::B {};
      |              ^
0x228dd45 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x229f296 internal_error(char const*, ...)
        ???:0
0x7d44da fancy_abort(char const*, int, char const*)
        ???:0
0x80f5bc popclass()
        ???:0
0x91193b pop_inner_scope(tree_node*, tree_node*)
        ???:0
0x98246d c_parse_file()
        ???:0
0xa8c379 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.

Online demo: https://gcc.godbolt.org/z/Gosh7xTGj

Reply via email to