public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/97132] assume_aligned is not constexpr Date: Mon, 21 Sep 2020 08:34:19 +0000 [thread overview] Message-ID: <bug-97132-4-aU2JFsQeGn@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-97132-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97132 --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #2) > I think there is no compliant way to test alignment assumptions during > constant evaluations and after all, one should always see the actual objects > and therefore can check the exact alignment, rather than needing any > assumptions. Right, during CE unaligned objects are UB anyway and not allowed. And the function is only supposed to benefit the optimiser, which isn't relevant during CE. > So, I think it doesn't really matter if this is done on the libstdc++ say > through not using __builtin_assume_aligned if std::is_constant_evaluated() > or on the C++ FE side (folding __builtin_assume_aligned to the first > argument during manifestly constant evaluation). I'll test this: { static_assert(std::has_single_bit(_Align)); _GLIBCXX_DEBUG_ASSERT((std::uintptr_t)__ptr % _Align == 0); - return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Align)); + if (std::is_constant_evaluated()) + return __ptr; + else + return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Align)); } #endif // C++2a
next prev parent reply other threads:[~2020-09-21 8:34 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-21 4:52 [Bug libstdc++/97132] New: " fsb4000 at yandex dot ru 2020-09-21 7:39 ` [Bug libstdc++/97132] " redi at gcc dot gnu.org 2020-09-21 8:01 ` jakub at gcc dot gnu.org 2020-09-21 8:34 ` redi at gcc dot gnu.org [this message] 2020-09-21 8:38 ` fsb4000 at yandex dot ru 2020-09-21 13:29 ` cvs-commit at gcc dot gnu.org 2020-10-19 21:25 ` cvs-commit at gcc dot gnu.org 2020-10-19 21:25 ` cvs-commit at gcc dot gnu.org 2020-10-19 21:34 ` redi 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-97132-4-aU2JFsQeGn@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).