From fe05eacbde94bb35e74a4e28f941bb97b518342a Mon Sep 17 00:00:00 2001
From: Felix Thaler <thaler@cscs.ch>
Date: Wed, 24 Jul 2024 08:18:18 +0200
Subject: [PATCH] Unconditional lookup in neighbor table

---
 include/gridtools/fn/unstructured.hpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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 <class Tag, class Ptr, class Strides, class Domain, class Conn, class Offset>
         GT_FUNCTION constexpr auto horizontal_shift(iterator<Tag, Ptr, Strides, Domain> const &it, Conn, Offset) {
             auto const &table = host_device::at_key<Conn>(it.m_domain.m_tables);
-            auto new_index = it.m_index == -1 ? -1 : get<Offset::value>(neighbor_table::neighbors(table, it.m_index));
+            auto new_index = get<Offset::value>(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;
         }