libstdc++: Fix std::to_address for debug iterators (PR 93960)
authorJonathan Wakely <jwakely@redhat.com>
Fri, 3 Apr 2020 09:42:20 +0000 (10:42 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 3 Apr 2020 09:42:20 +0000 (10:42 +0100)
commit24fe8c8e338e1c820d942b9c7b997a37705eb29e
tree65a23ce2fbccca770f58214ecd7c7c277d1abbf2
parent2b1e849b35bfe694b09f090397944e11c9f1dc04
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.

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]