public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "eteran at alum dot rit.edu" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/108645] Change in behavior, std::accumulate doesn't always work as expected in C++20 builds Date: Thu, 02 Feb 2023 21:05:29 +0000 [thread overview] Message-ID: <bug-108645-4-gq4PP9Xq2j@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108645-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108645 --- Comment #1 from Evan Teran <eteran at alum dot rit.edu> --- To further experiment, i factored out `std::accumulate`: ``` #include <vector> #include <iostream> #include <string> #include <iterator> void print_v(const char *rem, const std::vector<std::string> &v) { std::cout << rem; for (const std::string &s : v) std::cout << '"' << s << '"' << ' '; std::cout << '\n'; } int main() { std::vector<std::string> v = {"this", "_", "is", "_", "an", "_", "example"}; print_v("Old contents of the vector: ", v); std::string concat; auto first = std::make_move_iterator(v.begin()); auto last = std::make_move_iterator(v.end()); for (; first != last; ++first) { #if __cplusplus >= 202002L concat = std::move(concat) + *first; #else concat = concat + *first; #endif } print_v("New contents of the vector: ", v); std::cout << "Concatenated as string: " << '"' << concat << '"' << '\n'; } ``` Which results in the same behavior, so it appears to be that the: ``` basic_string operator+(basic_string &&, basic_string &&) ``` Overload doesn't steal the guts of the rhs at all? But the ``` basic_string operator+(const basic_string &, basic_string &&) ``` overload does?
next prev parent reply other threads:[~2023-02-02 21:05 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-02 21:00 [Bug libstdc++/108645] New: " eteran at alum dot rit.edu 2023-02-02 21:05 ` eteran at alum dot rit.edu [this message] 2023-02-03 1:40 ` [Bug libstdc++/108645] " pinskia at gcc dot gnu.org 2023-02-03 9:32 ` redi at gcc dot gnu.org 2023-02-03 10:01 ` redi at gcc dot gnu.org 2023-02-03 10:08 ` 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-108645-4-gq4PP9Xq2j@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).