From 71684bfe2c338e2693c5999c2f4c56f26c548f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Fri, 7 Jun 2024 14:27:02 +0200 Subject: [PATCH] Ensure 'mid' is always initialized. --- .../linalg/cuistl/detail/cusparse_matrix_operations.cu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opm/simulators/linalg/cuistl/detail/cusparse_matrix_operations.cu b/opm/simulators/linalg/cuistl/detail/cusparse_matrix_operations.cu index 27293a815..001052297 100644 --- a/opm/simulators/linalg/cuistl/detail/cusparse_matrix_operations.cu +++ b/opm/simulators/linalg/cuistl/detail/cusparse_matrix_operations.cu @@ -286,10 +286,9 @@ namespace // we binary search over int left = rowIndices[col]; int right = rowIndices[col + 1] - 1; - int mid; + int mid = left + (right - left) / 2; // overflow-safe average; while (left <= right) { - mid = left + (right - left) / 2; // overflow-safe average const int col = colIndices[mid]; if (col == naturalRowIdx) { @@ -299,6 +298,7 @@ namespace } else { right = mid - 1; } + mid = left + (right - left) / 2; // overflow-safe average } const int symOpposite = mid;