https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112795
--- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:67762f3d76d42b2d9a436b6279fd111082f47c2b commit r11-11151-g67762f3d76d42b2d9a436b6279fd111082f47c2b Author: Jakub Jelinek <ja...@redhat.com> Date: Mon Dec 4 08:59:15 2023 +0100 c++: #pragma GCC unroll C++ fixes [PR112795] foo in the unroll-5.C testcase ICEs because cp_parser_pragma_unroll during parsing calls maybe_constant_value unconditionally, which is fine if !processing_template_decl, but can ICE otherwise. While just calling fold_non_dependent_expr there instead could be enough to fix the ICE (and I guess the right thing to do for backports if any), I don't see a reason why we couldn't handle a dependent #pragma GCC unroll argument as well, the unrolling isn't done in the FE and all the middle-end cares about is that ANNOTATE_EXPR has a 1..65534 last operand when it is annot_expr_unroll_kind. So, the following patch changes all the unsigned short unroll arguments to tree unroll (and thus avoids the tree -> unsigned short -> tree conversions), does the type and value checking during parsing only if the argument isn't dependent and repeats it during instantiation. 2023-12-04 Jakub Jelinek <ja...@redhat.com> PR c++/112795 gcc/cp/ * parser.c (cp_parser_pragma_unroll): Use fold_non_dependent_expr instead of maybe_constant_value. gcc/testsuite/ * g++.dg/ext/unroll-5.C: New test. (cherry picked from commit b6c78feea08c36e5754818c6a3d7536b3f8913dc)