Re: [patch] libstdc++/65352 fix ubsan errors in std::array

2015-05-28 Thread Jonathan Wakely
On 28/05/15 12:53 +0100, Jonathan Wakely wrote: Unsurprisingly ubsan doesn't like referencing a null pointer. With this change __array_traits::_S_ref is only used to access an element, which is invalid for std::array anyway. Tested powerpc64le-linux, committed to trunk. I forgot the debug and

Re: [patch] libstdc++/65352 fix ubsan errors in std::array

2015-05-28 Thread Jonathan Wakely
On 28/05/15 15:52 +0200, Marc Glisse wrote: On Thu, 28 May 2015, Jonathan Wakely wrote: Would there be a danger of an object compiled with gcc-5.1 that calls array::data() finding the _S_ref from an object compiled with gcc-5.2 and hitting the __builtin_unreachable in vali code? At -O0, maybe

Re: [patch] libstdc++/65352 fix ubsan errors in std::array

2015-05-28 Thread Marc Glisse
On Thu, 28 May 2015, Jonathan Wakely wrote: Would there be a danger of an object compiled with gcc-5.1 that calls array::data() finding the _S_ref from an object compiled with gcc-5.2 and hitting the __builtin_unreachable in vali code? At -O0, maybe. To be safe you would need to give this _S_r

Re: [patch] libstdc++/65352 fix ubsan errors in std::array

2015-05-28 Thread Jonathan Wakely
On 28/05/15 15:26 +0200, Marc Glisse wrote: On Thu, 28 May 2015, Jonathan Wakely wrote: Unsurprisingly ubsan doesn't like referencing a null pointer. With this change __array_traits::_S_ref is only used to access an element, which is invalid for std::array anyway. Should return *static_cast

Re: [patch] libstdc++/65352 fix ubsan errors in std::array

2015-05-28 Thread Jonathan Wakely
On 28/05/15 14:38 +0100, Jonathan Wakely wrote: On 28/05/15 15:26 +0200, Marc Glisse wrote: On Thu, 28 May 2015, Jonathan Wakely wrote: Unsurprisingly ubsan doesn't like referencing a null pointer. With this change __array_traits::_S_ref is only used to access an element, which is invalid for

Re: [patch] libstdc++/65352 fix ubsan errors in std::array

2015-05-28 Thread Marc Glisse
On Thu, 28 May 2015, Jonathan Wakely wrote: Unsurprisingly ubsan doesn't like referencing a null pointer. With this change __array_traits::_S_ref is only used to access an element, which is invalid for std::array anyway. Should return *static_cast<_Tp*>(nullptr); be replaced with __builtin

Re: [patch] libstdc++/65352 fix ubsan errors in std::array

2015-05-28 Thread Jonathan Wakely
On 28/05/15 12:53 +0100, Jonathan Wakely wrote: Unsurprisingly ubsan doesn't like referencing a null pointer. With this change __array_traits::_S_ref is only used to access an element, which is invalid for std::array anyway. Tested powerpc64le-linux, committed to trunk. And gcc-5-branch. co

[patch] libstdc++/65352 fix ubsan errors in std::array

2015-05-28 Thread Jonathan Wakely
Unsurprisingly ubsan doesn't like referencing a null pointer. With this change __array_traits::_S_ref is only used to access an element, which is invalid for std::array anyway. Tested powerpc64le-linux, committed to trunk. commit 0d999cf16b8f6a0d9bbf4bfe96b29e7b73a259e4 Author: Jonathan Wakely