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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:f0c0bced62b9c728ed1e672747aa234d918da22c

commit r15-759-gf0c0bced62b9c728ed1e672747aa234d918da22c
Author: Patrick Palka <ppa...@redhat.com>
Date:   Tue May 21 15:54:10 2024 -0400

    c++: folding non-dep enumerator from current inst [PR115139]

    After the tsubst_copy removal r14-4796-g3e3d73ed5e85e7 GCC 14 ICEs during
    fold_non_dependent_expr for 'e1 | e2' below ultimately because we no
    longer exit early when substituting the CONST_DECLs for e1 and e2 with
    args=NULL_TREE and instead proceed to substitute the class context A<Ts...>
    (also with args=NULL_TREE) which ends up ICEing from tsubst_pack_expansion
    (due to processing_template_decl being cleared).

    Incidentally, the ICE went away on trunk ever since the tsubst_aggr_type
    removal r15-123-gf04dc89a991ddc since it changed the CONST_DECL case of
    tsubst_expr to use tsubst to substitute the context, which short circuits
    for empty args and so avoids the ICE.

    This patch fixes this ICE for GCC 14 by narrowly restoring the early exit
    for empty args that would've happened in tsubst_copy when substituting an
    enumerator CONST_DECL.  We might as well apply this to trunk too, as a
    small optimization.

            PR c++/115139

    gcc/cp/ChangeLog:

            * pt.cc (tsubst_expr) <case CONST_DECL>: Exit early if args
            is empty.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/non-dependent33.C: New test.

    Reviewed-by: Marek Polacek <mpola...@redhat.com>
    Reviewed-by: Jason Merrill <ja...@redhat.com>

Reply via email to