]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix std::to_address for debug iterators (PR 93960)
authorJonathan Wakely <jwakely@redhat.com>
Fri, 3 Apr 2020 11:00:07 +0000 (12:00 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 3 Apr 2020 11:00:07 +0000 (12:00 +0100)
commitb20b7f7e88fd40a76f422838ed5ba64e33814d91
tree3ffea988f875381f8a4dc4bab99a8ca2465afc35
parent69df6742cb4e15fba5ee074629a78811e61f044d
libstdc++: Fix std::to_address for debug iterators (PR 93960)

It should be valid to use std::to_address on a past-the-end iterator,
but the debug mode iterators do a check for dereferenceable in their
operator->(). That check is generally useful, so rather than remove it
this changes std::__to_address to identify a debug mode iterator and
use base().operator->() to skip the check.

Backport from mainline
2020-04-03  Jonathan Wakely  <jwakely@redhat.com>

PR libstdc++/93960
* include/bits/ptr_traits.h (__to_address): Add special case for debug
iterators, to avoid dereferenceable check.
* testsuite/20_util/to_address/1_neg.cc: Adjust dg-error line number.
* testsuite/20_util/to_address/debug.cc: New test.
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/ptr_traits.h
libstdc++-v3/testsuite/20_util/to_address/1_neg.cc
libstdc++-v3/testsuite/20_util/to_address/debug.cc [new file with mode: 0644]