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

Desmond Gold <cooky.ykooc922 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cooky.ykooc922 at gmail dot com

--- Comment #8 from Desmond Gold <cooky.ykooc922 at gmail dot com> ---
The following testcase ICEs on constexpr variable of consteval-only type inside
a runtime-evaluated function

using info = decltype(^^::);

// OK
constexpr info A {};
constexpr info B = ^^::;
inline constexpr info C = ^^::;

template <typename T>
struct S {
    // OK
    static constexpr info B {^^T};

    // wont ICE during template definition
    // but ICE during template instantiation
    // (1)
    void wow() {
        constexpr info D {^^T};
    }
};

consteval void foo() {
    info A = ^^::;
    constexpr info B = ^^::;
}

constexpr void bar() {
    constexpr info A = ^^::;
    static constexpr info B = ^^::;
}

constexpr void tux() {
    if consteval {
        constexpr info A = ^^::;
        // static constexpr info B = ^^::;
    }
}

void qux() {
    // ICE
    // constexpr info A {};
    // constexpr info B = ^^::;
    // static constexpr info C = ^^::;

    // OK: since it is constant evaluated
    foo();
    consteval { bar(); }
    consteval { tux(); }

    // OK: since the runtime evaluation doesn't contain
    //     the consteval branch
    tux();

    // ICE
    // bar();
}

// triggers ICE on (1)
// template struct S <int>;

When uncommenting the lines that are labeled ICE, each line will have the same
following ICE output:
<source>:LL:CC: internal compiler error: Segmentation fault
   57 | }
      | ^
0x291e078 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2912e6b internal_error(char const*, ...)
        ???:0

I run the testcase using https://godbolt.org/z/d8EY1TPdK. I don't know if this
has been fixed since the branch is based on gcc-reflection-trunk-20251031.

Reply via email to