[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 Jonathan Wakely changed: What|Removed |Added Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed||2022-04-13
[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 --- Comment #1 from Jonathan Wakely --- The simplest solution would be to just use std::allocator which already does the right thing, but that would break if there is a program-defined specialization of std::allocator.
[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 Jonathan Wakely changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org --- Comment #2 from Jonathan Wakely --- Created attachment 52799 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52799&action=edit Patch to support extended alignment This needs a testsuite addition, and should probably wait for GCC 13 now.
[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 Jonathan Wakely changed: What|Removed |Added Target Milestone|--- |13.0
[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 Richard Biener changed: What|Removed |Added Target Milestone|13.0|13.2 --- Comment #3 from Richard Biener --- GCC 13.1 is being released, retargeting bugs to GCC 13.2.
[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 Jakub Jelinek changed: What|Removed |Added Target Milestone|13.3|13.4 --- Comment #5 from Jakub Jelinek --- GCC 13.3 is being released, retargeting bugs to GCC 13.4.
[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 Marco Porsch changed: What|Removed |Added CC||Marco.Porsch at intenta dot de --- Comment #6 from Marco Porsch --- When compiled to ARM NEON vector operations, which have strict alignment requirements, this issue causes a kernel alignment trap and SIGBUS. See godbolt [1] for an example using Eigen matrix library. Compiled with clang, the instruction `vst1.64 {d16, d17}, [r0:128]` is generated which crashes if the pointer value is not aligned properly. I created a corresponding ticket with Eigen [2] which points to this issue and has extra info. Looking at the stdlib implementation of libc++ [3] and MSVC [4] I see a similar approach as proposed in the attached patch. [1] https://godbolt.org/z/1TxcTzz53 [2] https://gitlab.com/libeigen/eigen/-/issues/2826 [3] https://github.com/llvm/llvm-project/blob/main/libcxx/include/__memory/temporary_buffer.h#L26 [4] https://github.com/microsoft/STL/blob/main/stl/inc/xmemory#L1541
[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 --- Comment #7 from Jonathan Wakely --- The patch needs a little refactoring to share code with std::stacktrace, but it will be fixed soon.
[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 Jonathan Wakely changed: What|Removed |Added Keywords||patch URL||https://gcc.gnu.org/piperma ||il/gcc-patches/2024-June/65 ||3296.html --- Comment #8 from Jonathan Wakely --- Patch posted: https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653296.html
[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 --- Comment #9 from GCC Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:b0efdcbf58a76af3b8fff75f1d53d334fb5b46ee commit r15-997-gb0efdcbf58a76af3b8fff75f1d53d334fb5b46ee Author: Jonathan Wakely Date: Wed Apr 13 13:03:44 2022 +0100 libstdc++: Handle extended alignment in std::get_temporary_buffer [PR105258] This adds extended alignment support to std::get_temporary_buffer etc. so that when std::stable_sort uses a temporary buffer it works for overaligned types. Also simplify the _Temporary_buffer type by using RAII for the allocation, via a new data member. This simplifies the _Temporary_buffer constructor and destructor by makingthem only responsible for constructing and destroying the elements, not managing the memory. libstdc++-v3/ChangeLog: PR libstdc++/105258 * include/bits/stl_tempbuf.h (__detail::__get_temporary_buffer): New function to do allocation for get_temporary_buffer, with extended alignment support. (__detail::__return_temporary_buffer): Support extended alignment. (get_temporary_buffer): Use __get_temporary_buffer. (return_temporary_buffer): Support extended alignment. Add deprecated attribute. (_Temporary_buffer): Move allocation and deallocation into a subobject and remove try-catch block in constructor. (__uninitialized_construct_buf): Use argument deduction for value type. * testsuite/20_util/temporary_buffer.cc: Add dg-warning for new deprecated warning. * testsuite/25_algorithms/stable_sort/overaligned.cc: New test.
[Bug libstdc++/105258] std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 Richard Biener changed: What|Removed |Added Target Milestone|13.2|13.3 --- Comment #4 from Richard Biener --- GCC 13.2 is being released, retargeting bugs to GCC 13.3.