[patch] libstdc++/65352 fix ubsan errors in std::array<T, 0>

Marc Glisse marc.glisse@inria.fr
Thu May 28 13:27:00 GMT 2015


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.

-- 
Marc Glisse



More information about the Libstdc++ mailing list