This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch] libstdc++/65352 fix ubsan errors in std::array<T, 0>
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 28 May 2015 15:26:46 +0200 (CEST)
- Subject: Re: [patch] libstdc++/65352 fix ubsan errors in std::array<T, 0>
- Authentication-results: sourceware.org; auth=none
- References: <20150528115330 dot GL2985 at redhat dot com>
- Reply-to: libstdc++ at gcc dot gnu dot org
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