https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108110
--- Comment #11 from Martin Liška <marxin at gcc dot gnu.org> --- A bit more reduced test-case: namespace std { template <int __v> struct integral_constant { static constexpr int value = __v; }; template <typename _Tp> using decay_t = _Tp; template <bool, typename _Tp> using enable_if_t = _Tp; template <typename _Tp> _Tp &&forward(_Tp &); long max(long __b) { if (__b) return __b; } } // namespace std enum layout_type { row_major }; struct svector { long operator[](long) const; long *m_begin; }; auto svector::operator[](long idx) const -> long { 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>; struct xrange { xrange() noexcept; int 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> get(long size) { if (m_start) std::max(size); if (m_stop) std::max(size); return xrange(); } 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::integral_constant<true>) { return slice < std::decay_t<SL>() ?: 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 __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); } xrange::xrange() noexcept {} template <class D> struct xcontainer { using derived_type = D; using inner_shape_type = typename xcontainer_inner_types<D>::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 typename xcontainer<D>::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 inner_shape_type = SC; }; template <class, layout_type L, class, class> struct xarray_container : xstrided_container<xarray_container<double, L, svector>> {}; struct xview { template <class CTA, class FSL> xview(CTA, FSL); }; template <class E, class... S> void make_view_impl(E e, S &&...slices) { xview(get_slice_implementation(e, std::forward(slices))...); } template <class E, class... S> void view(E e, S... slices) { make_view_impl(e, slices...); } void TestBody() { xarray<double> a, arr; xrange_adaptor __trans_tmp_3 = range(1, 4), __trans_tmp_4 = range(1, 3); view(a, 1, __trans_tmp_3); view(arr, 1, __trans_tmp_4); }