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

            Bug ID: 122256
           Summary: ICE: unexpected expression ‘One` of kind
                    template_parm_index/Segmentation Fault from base
                    method in constraint
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chris at pcserenity dot com
  Target Milestone: ---

Created attachment 62543
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62543&action=edit
.out/.ii of code form one (template_parm_index)

Occurs on trunk.

There are two variants of this that I believe to be related. The first is the
furthest I could reduce the MRE while still keeping the overall code the same
as the original in which I encountered the bug. The second, is slightly closer
to the original in that Foo is a template struct, which results an a
segmentation fault instead of "unexpected expression ‘One’ of kind
template_parm_index".

May relate to 120041.

Command (excluding bug reporting specific switches): -std=c++20 -c input.cpp

First:
------

CE: https://godbolt.org/z/zfK8Goj9M

--------------- BEGIN SNIPPET ONE (template_param_index)
-------------------------

struct Bar {
    static consteval bool enabled(int) { return true; }
};

template <int One, int Two>
struct Baz : Bar {
    Baz() requires(enabled(Two)) {}
};

int main() {
    Baz<4, 5> baz{};
}

------------------------------- END SNIPPET ONE
----------------------------------

Second:
-------

CE: https://godbolt.org/z/n81WKrTdx

----------------- BEGIN SNIPPET TWO (segmentation fault)
-----------------------

template<int N>
struct Foo {};

struct Bar {
    static consteval bool enabled(int) { return true; }
};

template <Foo One, int Two>
struct Baz : Bar {
    Baz() requires(enabled(Two)) {}
};

int main() {
    Baz<Foo<4>{}, 5> baz{};
}

------------------------------- END SNIPPET TWO
----------------------------------

Reply via email to