+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.
+
2020-04-01 Andrea Corallo <andrea.corallo@arm.com>
* testsuite/experimental/net/execution_context/use_service.cc:
#include <bits/move.h>
+#if __cplusplus > 201703L
+namespace __gnu_debug { struct _Safe_iterator_base; }
+#endif
+
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Ptr, typename... _None>
constexpr auto
__to_address(const _Ptr& __ptr, _None...) noexcept
- { return std::__to_address(__ptr.operator->()); }
+ {
+ if constexpr (is_base_of_v<__gnu_debug::_Safe_iterator_base, _Ptr>)
+ return std::__to_address(__ptr.base().operator->());
+ else
+ return std::__to_address(__ptr.operator->());
+ }
/**
* @brief Obtain address referenced by a pointer to an object
// { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } }
-// { dg-error "not a function pointer" "" { target *-*-* } 153 }
+// { dg-error "not a function pointer" "" { target *-*-* } 157 }
#include <memory>
--- /dev/null
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { target c++2a } }
+
+#include <debug/vector>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ __gnu_debug::vector<int> v{1, 2, 3};
+ auto p = std::to_address(v.end());
+ VERIFY( p == v.data() + v.size() );
+}
+
+int
+main()
+{
+ test01();
+}