From ac3efa775fc0013da35f118852a9284d26076d19 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 28 May 2015 17:00:09 +0100 Subject: [PATCH] re PR libstdc++/65352 (array::begin()/end() etc. forms a null reference and breaks on clang+ubsan) PR libstdc++/65352 * include/profile/array (array::data): Use _S_ptr. * include/debug/array (array::data): Likewise. From-SVN: r223838 --- libstdc++-v3/ChangeLog | 4 ++++ libstdc++-v3/include/debug/array | 4 ++-- libstdc++-v3/include/profile/array | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index aea089adef8..286197c3f6b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2015-05-28 Jonathan Wakely + PR libstdc++/65352 + * include/profile/array (array::data): Use _S_ptr. + * include/debug/array (array::data): Likewise. + PR libstdc++/65352 * include/std/array (__array_traits::_S_ptr): New function. (array::data): Use _S_ptr to avoid creating invalid reference. diff --git a/libstdc++-v3/include/debug/array b/libstdc++-v3/include/debug/array index 31d146e9356..411e816d315 100644 --- a/libstdc++-v3/include/debug/array +++ b/libstdc++-v3/include/debug/array @@ -216,11 +216,11 @@ namespace __debug pointer data() noexcept - { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); } + { return _AT_Type::_S_ptr(_M_elems); } const_pointer data() const noexcept - { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); } + { return _AT_Type::_S_ptr(_M_elems); } }; // Array comparisons. diff --git a/libstdc++-v3/include/profile/array b/libstdc++-v3/include/profile/array index a90e396cae3..5198bb3af9c 100644 --- a/libstdc++-v3/include/profile/array +++ b/libstdc++-v3/include/profile/array @@ -178,11 +178,11 @@ namespace __profile pointer data() noexcept - { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); } + { return _AT_Type::_S_ptr(_M_elems); } const_pointer data() const noexcept - { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); } + { return _AT_Type::_S_ptr(_M_elems); } }; // Array comparisons. -- 2.30.2