This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
array profile mode (was: Re: [patch] libstdc++/65352 fix ubsan errors in std::array<T, 0>)
- From: François Dumont <frs dot dumont at gmail dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 01 Jun 2015 21:36:00 +0200
- Subject: array profile mode (was: 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> <20150528144644 dot GS2985 at redhat dot com>
On 28/05/2015 16:46, Jonathan Wakely wrote:
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<T, 0> anyway.
Tested powerpc64le-linux, committed to trunk.
I forgot the debug and profile modes, fixed like so.
1) Why do we even have _profile::array? What's it for?
There is no profiling code in array, indeed. This is so just for
consistency with Debug mode. As soon as one of the alternative mode is
activated normal implementation is put within __cxx1998 namespace and
you need to provide an alternative implementation, potentially
referencing the latter.
I tried once to do:
namespace std
{
namespace __profile
{
template<typename _Tp, std::size_t _Nm>
using array = _GLIBCXX_STD_C::array<_Tp, _Nm>;
}
}
but it doesn't work as we can't expose a template alias to user code in
place of a struct.
So we could:
1. Have a special management of array in normal mode, not put it in
__cxx1998 when only profile mode is activated.
2. Use inheritance on the normal implementation to reduce amount of
duplicated code.
I will have a try in coming days.
François