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

--- Comment #3 from David Binderman <dcb314 at hotmail dot com> ---
Reduced C++ code seems to be:

namespace std {
template <int __v> struct integral_constant {
  static constexpr int value = __v;
};
using true_type = integral_constant<true>;
using false_type = integral_constant<false>;
template <int> struct __conditional {
  template <typename _Tp, typename> using type = _Tp;
};
template <bool _Cond, typename _If, typename _Else>
using __conditional_t = typename __conditional<_Cond>::type<_If, _Else>;
template <typename _Tp> struct remove_cv { using type = _Tp; };
template <typename _Tp> struct remove_reference { using type = _Tp; };
template <typename _Up>
struct __decay_selector
    : __conditional_t<false_type ::value, remove_cv<_Up>, _Up> {};
template <typename _Tp> struct decay {
  using type = typename __decay_selector<_Tp>::type;
};
template <typename _Tp> using decay_t = typename decay<_Tp>::type;
template <bool, typename _Tp> using enable_if_t = _Tp;
template <typename _Tp> _Tp &&forward(typename remove_reference<_Tp>::type &);
long max(long __b) {
  if (__b)
    return __b;
}
} // namespace std
enum layout_type { row_major };
template <class> struct svector {
  using size_type = long;
  using value_type = long;
  using const_reference = value_type;
  const_reference operator[](size_type) const;
  long *m_begin;
};
template <class T>
auto svector<T>::operator[](size_type idx) const -> const_reference {
  return m_begin[idx];
}
template <class> struct xcontainer_inner_types;
template <class, layout_type, class, class = int> class xarray_container;
template <class, layout_type L = row_major, class A = int>
using xarray = xarray_container<A, L, long>;
template <class> struct xrange {
  using size_type = int;
  xrange(size_type, size_type) noexcept;
  size_type m_size;
};
template <class, class, class> struct xrange_adaptor {
  xrange_adaptor(int, int, int) : m_start() {}
  std::enable_if_t<std::integral_constant<0>::value, xrange<long>>
  get(long size) {
    long __trans_tmp_8, __trans_tmp_7;
    if (m_start)
      std::max(size);
    if (m_stop)
      std::max(size);
    return xrange<long>(__trans_tmp_7, __trans_tmp_8);
  }
  int m_start;
  int m_stop;
};
template <class A, class B> auto range(A, B stop_val) {
  return xrange_adaptor<A, B, int>(0, stop_val, int());
}
template <class> struct slice_implementation_getter {
  template <class E, class SL> auto operator()(E e, SL slice, long index) {
    return get_slice(e, slice, index, std::integral_constant<1>());
  }
  template <class E, class SL>
  auto get_slice(E, SL slice, long, std::true_type) {
    using int_type = std::decay_t<SL>;
    return slice < int_type() ?: slice;
  }
};
template <class A, class B, class C>
struct slice_implementation_getter<xrange_adaptor<A, B, C>> {
  template <class E, class SL> auto operator()(E e, SL adaptor, long index) {
    const svector<long> __trans_tmp_6 = e.shape();
    long __trans_tmp_2 = __trans_tmp_6[index];
    return adaptor.get(__trans_tmp_2);
  }
};
long get_slice_implementation_index;
template <class E, class SL> auto get_slice_implementation(E e, SL &&slice) {
  slice_implementation_getter<std::decay_t<SL>> getter;
  return getter(e, slice, get_slice_implementation_index);
}
template <class T> xrange<T>::xrange(size_type, size_type) noexcept {}
template <class D> struct xcontainer {
  using derived_type = D;
  using inner_types = xcontainer_inner_types<D>;
  using inner_shape_type = typename inner_types::inner_shape_type;
  constexpr const inner_shape_type &shape() const noexcept;
  const derived_type &derived_cast() const &noexcept;
};
template <class D> struct xstrided_container : xcontainer<D> {
  using base_type = xcontainer<D>;
  using typename base_type::inner_shape_type;
  const inner_shape_type &shape_impl() const noexcept;
  inner_shape_type m_shape;
};
template <class D>
constexpr auto xcontainer<D>::shape() const noexcept
    -> const inner_shape_type & {
  return derived_cast().shape_impl();
}
template <class D>
auto xcontainer<D>::derived_cast() const &noexcept -> const derived_type & {
  return *static_cast<const derived_type *>(this);
}
template <class D>
auto xstrided_container<D>::shape_impl() const noexcept
    -> const inner_shape_type & {
  return m_shape;
}
template <class EC, layout_type L, class SC, class Tag>
struct xcontainer_inner_types<xarray_container<EC, L, SC, Tag>> {
  using shape_type = SC;
  using inner_shape_type = shape_type;
};
template <class, layout_type L, class, class>
struct xarray_container
    : xstrided_container<xarray_container<double, L, svector<long>>> {};
struct xview {
  template <class CTA, class FSL> xview(CTA, FSL);
};
template <class E, class... S> void make_view_impl(E e, S &&...slices) {
  using view_type = xview;
  view_type(get_slice_implementation(e, std::forward<S>(slices))...);
}
template <class E, class... S> void view(E e, S... slices) {
  make_view_impl(e, std::forward<S>(slices)...);
}
void TestBody() {
  xarray<double> a, arr;
  xrange_adaptor<int, int, int> __trans_tmp_3 = range(1, 4),
                                __trans_tmp_4 = range(1, 3);
  view(a, 1, __trans_tmp_3);
  view(arr, 1, __trans_tmp_4);
}

Reply via email to