https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93960
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-8 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:afae9879c28a2797c49bf2da51415da70cdd2b83 commit r8-10162-gafae9879c28a2797c49bf2da51415da70cdd2b83 Author: Jonathan Wakely <jwak...@redhat.com> Date: Fri Apr 3 12:00:07 2020 +0100 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 <jwak...@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.