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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:5ff9e21c1ec81f8288e74679547e56051e051975

commit r15-5043-g5ff9e21c1ec81f8288e74679547e56051e051975
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Fri Nov 8 13:36:05 2024 +0100

    c++: Fix ICE on constexpr virtual function [PR117317]

    Since C++20 virtual methods can be constexpr, and if they are
    constexpr evaluated, we choose tentative_decl_linkage for those
    defer their output and decide at_eof again.
    On the following testcases we ICE though, because if
    expand_or_defer_fn_1 decides to use tentative_decl_linkage, it
    returns true and the caller in that case cals emit_associated_thunks,
    where use_thunk which it calls asserts DECL_INTERFACE_KNOWN on the
    thunk destination, which isn't the case for tentative_decl_linkage.

    The following patch fixes the ICE by not emitting the thunks
    for the DECL_DEFER_OUTPUT fns just yet but waiting until at_eof
    time when we return to those.
    Note, the second testcase ICEs already since r0-110035 with -std=c++0x
    before it gets a chance to diagnose constexpr virtual method.

    2024-11-08  Jakub Jelinek  <ja...@redhat.com>

            PR c++/117317
            * semantics.cc (emit_associated_thunks): Do nothing for
            !DECL_INTERFACE_KNOWN && DECL_DEFER_OUTPUT fns.

            * g++.dg/cpp2a/pr117317-1.C: New test.
            * g++.dg/cpp2a/pr117317-2.C: New test.

Reply via email to