diff --git a/include/gridtools/fn/unstructured.hpp b/include/gridtools/fn/unstructured.hpp index 3793f95ee..7e57a4692 100644 --- a/include/gridtools/fn/unstructured.hpp +++ b/include/gridtools/fn/unstructured.hpp @@ -86,9 +86,9 @@ namespace gridtools::fn { template GT_FUNCTION constexpr auto horizontal_shift(iterator const &it, Conn, Offset) { auto const &table = host_device::at_key(it.m_domain.m_tables); - auto new_index = it.m_index == -1 ? -1 : get(neighbor_table::neighbors(table, it.m_index)); + auto new_index = get(neighbor_table::neighbors(table, std::max(it.m_index, 0))); auto shifted = it; - shifted.m_index = new_index; + shifted.m_index = it.m_index == -1 ? -1 : new_index; return shifted; }