This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
The polymorphic_allocator::construct functions create dangling pointers to rvalues of type memory_resource* and then dereference them, leading to undefined behaviour. This fixes those functions to use lvalues, and then adds a deleted overload of __use_alloc to prevent this happening again. This means __use_alloc can't be used like: f( __use_alloc<T, Alloc>(c.get_allocator()) ); because get_allocator() returns an rvalue, but it's an internal-only helper and we can just do this instead: auto alloc = c.get_allocator(); f( __use_alloc<T, Alloc>(alloc) );
* include/bits/uses_allocator.h (__use_alloc(const _Alloc&&)): Add deleted overload to prevent dangling references to rvalues. * include/experimental/memory_resource (polymorphic_allocator::construct): Do not call __use_alloc with rvalue arguments. Tested powerpc64le-linux, committed to trunk.
Attachment:
patch.txt
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |