public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/105258] New: std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
@ 2022-04-13  8:37 wielkiegie at gmail dot com
  2022-04-13 11:31 ` [Bug libstdc++/105258] " redi at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: wielkiegie at gmail dot com @ 2022-04-13  8:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258

            Bug ID: 105258
           Summary: std::get_temporary_buffer() does not respect alignment
                    (affects std::stable_sort())
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wielkiegie at gmail dot com
  Target Milestone: ---

Created attachment 52795
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52795&action=edit
The reproducer

The `std::get_temporary_buffer()` function uses raw `operator new()` to
allocate enough memory for the `sizeof(T) * count` bytes. However, it does not
take `alignof(T)` into account.

While `std::get_temporary_buffer()` is deprecated in C++17 [1], it is still
used internally by `std::stable_sort()`.

The issue is reproducible on the gcc HEAD [2]. Please note that the alignment
issues might not be deterministic as the allocator can return an allocation of
correct alignment by accident.

For convenience, I have also attached the reproducer to this bug report.

[1] https://en.cppreference.com/w/cpp/memory/get_temporary_buffer
[2] https://wandbox.org/permlink/zZt6Weh3V1XWmUWt

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-06-03 20:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13  8:37 [Bug libstdc++/105258] New: std::get_temporary_buffer() does not respect alignment (affects std::stable_sort()) wielkiegie at gmail dot com
2022-04-13 11:31 ` [Bug libstdc++/105258] " redi at gcc dot gnu.org
2022-04-13 11:33 ` redi at gcc dot gnu.org
2022-04-13 12:11 ` redi at gcc dot gnu.org
2022-04-13 12:11 ` redi at gcc dot gnu.org
2023-04-26  6:55 ` rguenth at gcc dot gnu.org
2023-07-27  9:22 ` rguenth at gcc dot gnu.org
2024-05-21  9:11 ` jakub at gcc dot gnu.org
2024-05-31  7:39 ` Marco.Porsch at intenta dot de
2024-05-31  9:58 ` redi at gcc dot gnu.org
2024-06-01 10:32 ` redi at gcc dot gnu.org
2024-06-03 20:18 ` cvs-commit at gcc dot gnu.org

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).