diff --git a/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h b/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h index 5ca39d49588..abb95f251d2 100644 --- a/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h +++ b/include/oneapi/dpl/pstl/hetero/dpcpp/parallel_backend_sycl_merge.h @@ -101,6 +101,9 @@ __serial_merge(const _Rng1& __rng1, const _Rng2& __rng2, _Rng3& __rng3, _Index _ const bool __rng1_idx_less_n1 = __rng1_idx < __rng1_idx_end; const bool __rng2_idx_less_n2 = __rng2_idx < __rng2_idx_end; + // Logically, one of __rng1_idx_less_n1 and __rng2_idx_less_n2 should be true here + // because 1) we should fill output data with elements from one of the input ranges + // 2) we calculate __rng3_idx_end as std::min<_Index>(__rng1_size + __rng2_size, __chunk); __rng3[__rng3_idx] = __rng1_idx_less_n1 && __rng2_idx_less_n2 ? (__comp(__rng2[__rng2_idx], __rng1[__rng1_idx]) ? __rng2[__rng2_idx++] : __rng1[__rng1_idx++])