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

Jonathan Wakely jwakely@redhat.com
Thu May 28 13:38:00 GMT 2015


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>.



More information about the Libstdc++ mailing list