From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4F9B13857C65; Fri, 1 Dec 2023 15:22:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F9B13857C65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701444147; bh=0K4UFU/H2ld9cV7ODfua3hqk8Z5iNMRtmDTFYE5vtEg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bLFQhnyBpxWgRBRFm/L+f/2/UnnSlzxhsShVYxdLW6bKhpzfAMu3DZAjQUknwyvTk sywB6c8eobkG0NfSzBGIpSKFwxXRAEv/r7rkNtgytNYT1XMI7WFFJzMF8wnyTPMuR9 U2x8WMfCEaTIifyP6ch4Inl5PT0aS6qpE0KBunpc= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112795] [C++>=14] ICE pragma GCC unroll (n) cxx_eval_constant_expression Date: Fri, 01 Dec 2023 15:22:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 8.1.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cc assigned_to Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112795 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |ebotcazou at gcc dot gnu.o= rg, | |jakub at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gn= u.org --- Comment #3 from Jakub Jelinek --- The bug is in calling expr =3D maybe_constant_value (expr); That is something that shouldn't be done in code possibly parsed in templat= es, unless !processing_template_decl. A quick fix would be to use expr =3D fold_non_dependent_expr (expr); and I guess I'll just submit a patch with that. That is e.g. what we do in OpenMP collapse clause parsing where we really w= ant a constant already during parsing because how we parse the following code depends on that. If that is not the case in #pragma GCC unroll, the normal C++ way would be = to only check if the result is INTEGER_CST etc. if it is not value dependent expr, otherwise pass down a tree and during instantiation instantiate that tree. That way template void foo () { #pragma GCC unroll(N) for (int i =3D 0; i !=3D N; ++i) ; } would be possible.=