aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include/cpplib.h
diff options
context:
space:
mode:
authorTomasz Kamiński <tkaminsk@redhat.com>2025-08-01 09:21:27 +0200
committerTomasz Kamiński <tkaminsk@redhat.com>2025-08-04 13:19:24 +0200
commitd49d359b0c5266b314bcf31405746909d99927a1 (patch)
tree4cca382922bf8fd8c66ba8d2564b82f23a316dc4 /libcpp/include/cpplib.h
parentd9f34c951ab1f5ba67f3a1c95e2533cff6230b85 (diff)
downloadgcc-d49d359b0c5266b314bcf31405746909d99927a1.zip
gcc-d49d359b0c5266b314bcf31405746909d99927a1.tar.gz
gcc-d49d359b0c5266b314bcf31405746909d99927a1.tar.bz2
libstdc++: Fix dereferencing of std::indirect xvalues [PR121128]
Forr rvalues the _Self parameter deduces a non-reference type. Consequently, ((_Self)__self) moved the object to a temporary, which then destroyed on function exit. This patch fixes this by using a C-style cast __self to (const indirect&). This not only resolves the above issue but also correctly handles types that are derived (publicly and privately) from indirect. Allocator requirements in [allocator.requirements.general] p22 guarantee that dereferencing const _M_objp works with equivalent semantics to dereferencing _M_objp. PR libstdc++/121128 libstdc++-v3/ChangeLog: * include/bits/indirect.h (indirect::operator*): Cast __self to approparietly qualified indirect. * testsuite/std/memory/indirect/access.cc: New test. * testsuite/std/memory/polymorphic/access.cc: New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Diffstat (limited to 'libcpp/include/cpplib.h')
0 files changed, 0 insertions, 0 deletions