public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-105233-4-NM3HrYjtX2@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-105233-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105233 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org, | |ppalka at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Even template <typename T> constexpr T foo (T x) noexcept { bool a = __builtin_is_constant_evaluated (); return 4 * __alignof (int); } template <typename T> struct A { T a, b, c; }; template <typename T> struct alignas (foo (sizeof (A<T>))) B { A<T> d; }; B<int> e; I see that the foo (sizeof (A<T>) 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 appear 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) = 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).
next prev parent reply other threads:[~2022-04-12 13:09 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-11 22:19 [Bug c++/105233] New: " Jonathan.Strobl at gmx dot de 2022-04-12 12:03 ` [Bug c++/105233] " jakub at gcc dot gnu.org 2022-04-12 12:19 ` jakub at gcc dot gnu.org 2022-04-12 12:34 ` jakub at gcc dot gnu.org 2022-04-12 13:09 ` jakub at gcc dot gnu.org [this message] 2022-04-12 13:50 ` jakub at gcc dot gnu.org 2022-04-12 13:59 ` ppalka at gcc dot gnu.org 2022-04-13 13:44 ` cvs-commit at gcc dot gnu.org 2022-04-13 13:46 ` jakub at gcc dot gnu.org 2022-04-13 15:46 ` Jonathan.Strobl at gmx dot de 2022-04-13 15:51 ` jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-105233-4-NM3HrYjtX2@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).