https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99117

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, based on IRC discussion, the problem is that in:
  template<typename _Tp> template<class _Dom>
    inline valarray<_Tp>&
    valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e)
    {
      // _GLIBCXX_RESOLVE_LIB_DEFECTS
      // 630. arrays of valarray.
      if (_M_size == __e.size())
        std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data));

the temporary _Array<_Tp>(_M_data) object's _M_data passed to __valarray_copy
doesn't fully own the object and that __e's operator[] aliases with that.
Can't libstdc++ for cases where such aliasing is possible use an _Array-like
class without the __restrict (i.e. something that wouldn't lie to the compiler
that it fully owns it)?

Reply via email to