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

            Bug ID: 124204
           Summary: [reflection] Internal compiler error when using
                    std::meta::substitute with a reference reflection: in
                    implicit_conversion, at cp/call.cc:2237
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: friedkeenan at protonmail dot com
  Target Milestone: ---

```
#include <meta>

template<int Object>
using dummy_template = void; 

constexpr int variable = 0;

constexpr auto &reference = variable;

constexpr auto result = substitute(^^dummy_template, {^^reference});
```
Godbolt link: https://godbolt.org/z/78axr75or


Crash output:
```
<source>:10:35: internal compiler error: in implicit_conversion, at
cp/call.cc:2237
   10 | constexpr auto result = substitute(^^dummy_template, {^^reference});
      |                         ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x2961fb8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2956cfb internal_error(char const*, ...)
        ???:0
0xb215b0 fancy_abort(char const*, int, char const*)
        ???:0
0xdb6b23 coerce_template_parms(tree_node*, tree_node*, tree_node*, int, bool)
        ???:0
0xda355e lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int)
        ???:0
0xdf1483 process_metafunction(constexpr_ctx const*, tree_node*, tree_node*,
bool*, bool*, tree_node**)
        ???:0
0xb8ebbc cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xba7979 maybe_constant_value(tree_node*, tree_node*, mce_value)
        ???:0
0xe75527 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xc2e1e6 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xd6ca93 c_parse_file()
        ???:0
0xef66f9 c_common_parse_file()
        ???:0
```

If one edits the code to instead use constant_of(^^reference) or
object_of(...), then the crash can be avoided.

To me this smells suspiciously similar to Bug 123044, but I'm not sure.
  • [Bug c++/124204] New: [refl... friedkeenan at protonmail dot com via Gcc-bugs

Reply via email to