public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hewillk at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/101608] ranges::fill/fill_n missing std::is_constant_evaluated() condition for __builtin_memset Date: Mon, 02 Aug 2021 17:14:37 +0000 [thread overview] Message-ID: <bug-101608-4-4BkbiC2U9v@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-101608-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101608 --- Comment #1 from 康桓瑋 <hewillk at gmail dot com> --- This may help: --- a/ranges_algobase.h +++ b/ranges_algobase.h @@ -525,16 +525,22 @@ namespace ranges if (__n <= 0) return __first; - // TODO: Generalize this optimization to contiguous iterators. - if constexpr (is_pointer_v<_Out> - // Note that __is_byte already implies !is_volatile. - && __is_byte<remove_pointer_t<_Out>>::__value - && integral<_Tp>) +#ifdef __cpp_lib_is_constant_evaluated + if (!std::is_constant_evaluated()) +#endif { - __builtin_memset(__first, static_cast<unsigned char>(__value), __n); - return __first + __n; + // TODO: Generalize this optimization to contiguous iterators. + if constexpr (is_pointer_v<_Out> + // Note that __is_byte already implies !is_volatile. + && __is_byte<remove_pointer_t<_Out>>::__value + && integral<_Tp>) + { + __builtin_memset(__first, static_cast<unsigned char>(__value), __n); + return __first + __n; + } } - else if constexpr (is_scalar_v<_Tp>) + + if constexpr (is_scalar_v<_Tp>) { const auto __tmp = __value; for (; __n > 0; --__n, (void)++__first)
next prev parent reply other threads:[~2021-08-02 17:14 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-07-24 4:00 [Bug libstdc++/101608] New: " hewillk at gmail dot com 2021-08-02 17:14 ` hewillk at gmail dot com [this message] 2021-11-23 16:55 ` [Bug libstdc++/101608] " redi at gcc dot gnu.org 2021-11-25 20:03 ` cvs-commit at gcc dot gnu.org 2021-11-25 23:07 ` cvs-commit at gcc dot gnu.org 2021-11-26 12:52 ` cvs-commit at gcc dot gnu.org 2021-11-26 14:28 ` 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-101608-4-4BkbiC2U9v@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).