This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

array profile mode (was: Re: [patch] libstdc++/65352 fix ubsan errors in std::array<T, 0>)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]