public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "D.Bahadir at GMX dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94082] __builtin_memcpy in constexpr context should compile Date: Mon, 09 Mar 2020 11:04:37 +0000 [thread overview] Message-ID: <bug-94082-4-x2JfMlwZwh@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94082-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94082 --- Comment #4 from Deniz Bahadir <D.Bahadir at GMX dot de> --- (In reply to Jonathan Wakely from comment #3) > (In reply to Deniz Bahadir from comment #1) > > Reading P0202 (wg21.link/p0202) (which made it into C++20) it sounds as if > > `__builtin_memcpy` should be usable from a `constexpr` context. > > Why? std::memcpy isn't usable in constant expressions. Revision 0 of P0202 (https://wg21.link/p0202r0) originally had the following text in section III.B: "B. std::memmove and std::memcpy must have constexpr additions std::memmove and std::memcpy accept void* and const void* parameters. This makes them impossible to implement in pure C++ as constexpr, because constant expressions can not evaluate a conversion from type cv void * to a pointer-to-object type according to [expr.const]. However those functions are not only popular, but also are widely used across Standard Library to gain better performance. Not making them constexpr will force standard Library developer to have compiler intrinsics for them anyway. This is a hard step that must be done." That was rejected at the committee meeting in Jacksonville in early 2018 and the section was replaced by the following: "During the Jacksonville meeting it was decided not to modify the <cstring> headers, leading to a decision to use compiler specific intrinsics instead of functions from <cstring> header." To me that sounds as if compiler-intrinsics like `__builtin_memcpy` should instead be usable in `constexpr` contexts. > It might be useful if it could be used, but the fact it can't currently > isn't a bug. OK, then consider this issue a feature-request and a question. As the link to Compiler Explorer shows the compiler is already able to calculate the result of the entire function call at compile-time when called from a non-`constexpr` context. Shouldn't it then be able to still do so in a `constexpr` context, too? (As I mentioned, e.g. for `__builtin_bswap32` that is possible.)
next prev parent reply other threads:[~2020-03-09 11:04 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-94082-4@http.gcc.gnu.org/bugzilla/> 2020-03-07 19:37 ` fche at redhat dot com 2020-03-08 13:25 ` D.Bahadir at GMX dot de 2020-03-08 13:27 ` D.Bahadir at GMX dot de 2020-03-09 9:45 ` redi at gcc dot gnu.org 2020-03-09 11:04 ` D.Bahadir at GMX dot de [this message] 2020-03-09 11:28 ` redi at gcc dot gnu.org 2020-03-09 12:04 ` D.Bahadir at GMX dot de 2021-08-28 21:57 ` pinskia 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-94082-4-x2JfMlwZwh@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).