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

            Bug ID: 105044
           Summary: [modules] ICE in comptypes, at cp/typeck.c:1529
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/YGo78aPE8.

`mod.cpp`:
```C++
export module mod;

export template<typename BaseType>
struct downcast_base {
  using downcast_base_type = BaseType;
  friend auto downcast_guide(downcast_base);
};

export template<typename T> concept Downcastable = true;

export template<typename Target, Downcastable T>
struct downcast_child : T {
  friend auto downcast_guide(typename T::downcast_base) { return T(); }
};

export struct ratio { int num; };

export template<ratio R, typename U>
struct scaled_unit : downcast_base<scaled_unit<R, U>> {};

export template<typename Child>
struct unit : downcast_child<Child, scaled_unit<ratio(1), Child>> {};

export struct unknown_coherent_unit : unit<unknown_coherent_unit> {};
```

`test.cpp`:
```C++
import mod;
struct u : downcast_base<u> { };
int main() { }
```

Output:
```
In module mod, imported at /app/test.cpp:1:
mod.cpp: In instantiation of 'struct downcast_base@mod<u>':
test.cpp:2:12:   required from here
mod.cpp:4:8: internal compiler error: in comptypes, at cp/typeck.cc:1529
    4 | struct downcast_base {
      |        ^~~~~~~~~~~~~
0x218c519 internal_error(char const*, ...)
        ???:0
0x741b3f fancy_abort(char const*, int, char const*)
        ???:0
0xa7e346 comptypes(tree_node*, tree_node*, int)
        ???:0
0x828f6d complete_vars(tree_node*)
        ???:0
0x7a1a5c finish_struct_1(tree_node*)
        ???:0
0xa01359 instantiate_class_template(tree_node*)
        ???:0
0xa7739b complete_type_or_maybe_complain(tree_node*, tree_node*, int)
        ???:0
0x841a1c xref_basetypes(tree_node*, tree_node*)
        ???:0
0x986b0d c_parse_file()
        ???:0
0xb18ae2 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.
See <https://gcc.gnu.org/bugs/> for instructions.
```

Reply via email to