From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AE9323858C56; Tue, 12 Apr 2022 13:09:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE9323858C56 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105233] Incorrect "alignment not an integer constant" error in alignas with template parameter dependent argument Date: Tue, 12 Apr 2022 13:09:54 +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: 11.2.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2022 13:09:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105233 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org, | |ppalka at gcc dot gnu.org --- Comment #4 from Jakub Jelinek --- Even template constexpr T foo (T x) noexcept { bool a =3D __builtin_is_constant_evaluated (); return 4 * __alignof (int); } template struct A { T a, b, c; }; template struct alignas (foo (sizeof (A))) B { A d; }; B e; I see that the foo (sizeof (A) expression is constexpr evaluated once without manifestly_const_eval and with allow_non_constant set, so because of the __builtin_is_constant_evaluated () fails in that case, as it isn't a manifestly constant evaluation but manifestly constant evaluation could app= ear later. It isn't evaluated with it later though. alignas argument is a constant expression (or type id), so at some point it should be evaluated with manifestly_const_eval set. Under the hood, we transform alignas into the gnu::aligned attribute, so the question is, shall we treat as manifestly constant expression just alignas argument, or gnu::aligned attribute's argument as well, or some other attribute's arguments too? And where exactly we'd evaluate those arguments? Seems the C++ FE has cp_check_const_attributes for this, but there it just calls: if (EXPR_P (expr)) TREE_VALUE (arg) =3D fold_non_dependent_expr (expr); which is non-manifestly constant evaluated and doesn't guarantee it will be= a constant expression (we then just error if it is not later on).=