[Bug c++/99790] [8/9/10/11 Regression] internal compiler error: in expand_expr_real_2 since r7-3811

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Mar 30 16:16:19 GMT 2021


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

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

https://gcc.gnu.org/g:953624089be3f51c2ebacba65be8521bf6ae8430

commit r11-7914-g953624089be3f51c2ebacba65be8521bf6ae8430
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Mar 30 18:15:32 2021 +0200

    c++: Fix ICE on PTRMEM_CST in lambda in inline var initializer [PR99790]

    The following testcase ICEs (since the addition of inline var support),
    because the lambda contains PTRMEM_CST but finish_function is called for
the
    lambda quite early during parsing it (from finish_lambda_function) when
    the containing class is still incomplete.  That means that during
    genericization cplus_expand_constant keeps the PTRMEM_CST unmodified, but
    later nothing lowers it when the class is finalized.
    Using sizeof etc. on the class in such contexts is rejected by both g++ and
    clang++, and when the PTRMEM_CST appears e.g. in static var initializers
    rather than in functions, we handle it correctly because
c_parse_final_cleanups
    -> lower_var_init will handle those cplus_expand_constant when all classes
    are already finalized.

    The following patch fixes it by calling cplus_expand_constant again during
    gimplification, as we are now unconditionally unit at a time, I'd think
    everything that could be completed will be before we start gimplification.

    2021-03-30  Jakub Jelinek  <jakub@redhat.com>

            PR c++/99790
            * cp-gimplify.c (cp_gimplify_expr): Handle PTRMEM_CST.

            * g++.dg/cpp1z/pr99790.C: New test.


More information about the Gcc-bugs mailing list