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 std::array<T, 0> anyway.

Should

return *static_cast<_Tp*>(nullptr);

be replaced with

__builtin_unreachable();

then? It seems strange to keep an implementation that is never supposed to be used.

That's a good idea, I experimented with just not defining it but that
fails for explicit instantiations of array<T, 0>.

Would there be a danger of an object compiled with gcc-5.1 that calls
array<T, 0>::data() finding the _S_ref from an object compiled with
gcc-5.2 and hitting the __builtin_unreachable in vali code?

Reply via email to