[Bug libstdc++/108645] Change in behavior, std::accumulate doesn't always work as expected in C++20 builds

2023-02-03 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108645 --- Comment #5 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #3) > In your example, all your strings fit in the SSO buffer inside the > std::string object, so the LHS has sufficient capacity for the result. Actually that's

[Bug libstdc++/108645] Change in behavior, std::accumulate doesn't always work as expected in C++20 builds

2023-02-03 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108645 --- Comment #4 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #3) > const auto __size = __lhs.size() + __rhs.size(); > if (__size > __lhs.capacity() && __size <= __rhs.capacity()) > return

[Bug libstdc++/108645] Change in behavior, std::accumulate doesn't always work as expected in C++20 builds

2023-02-03 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108645 --- Comment #3 from Jonathan Wakely --- (In reply to Evan Teran from comment #1) > Which results in the same behavior, so it appears to be that the: > > ``` > basic_string operator+(basic_string &&, basic_string &&) > ``` > > Overload doesn't

[Bug libstdc++/108645] Change in behavior, std::accumulate doesn't always work as expected in C++20 builds

2023-02-02 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108645 --- Comment #2 from Andrew Pinski --- >Tested with both clang and gcc trunk, so it seems to be a library level issue. I tested clang with -stdlib=libc++ and it produces the same results as without that option (which is it uses gcc's

[Bug libstdc++/108645] Change in behavior, std::accumulate doesn't always work as expected in C++20 builds

2023-02-02 Thread eteran at alum dot rit.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108645 --- Comment #1 from Evan Teran --- To further experiment, i factored out `std::accumulate`: ``` #include #include #include #include void print_v(const char *rem, const std::vector ) { std::cout << rem; for (const