From: Jonathan Wakely Date: Thu, 28 May 2015 16:00:09 +0000 (+0100) Subject: re PR libstdc++/65352 (array::begin()/end() etc. forms a null reference and... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac3efa775fc0013da35f118852a9284d26076d19;p=gcc.git 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 --- 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.