Skip to content

Commit 00816b2

Browse files
committed
fix(tests): Fix narrowing conversion in sparse vector neighbor exchange test
Add static_cast<size_t> to avoid narrowing conversion errors when compiling with clang. Fixes compilation failure in CI for clang-14 and clang-16 builds. Changes: - Line 248: Cast rank * 100 expressions to size_t - Line 253: Cast rank * 200 expressions to size_t Resolves CI error: non-constant-expression cannot be narrowed from type 'int' to 'unsigned long' in initializer list [-Wc++11-narrowing]
1 parent 7189de9 commit 00816b2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/unit/core/test_sparse_vector_neighbor_exchange.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,14 @@ TEST_CASE("Neighbor exchange - Multiple neighbors simultaneously",
245245
int right_neighbor = (rank + 1) % size;
246246

247247
// Create data for each direction
248-
std::vector<size_t> left_indices = {rank * 100, rank * 100 + 1};
248+
std::vector<size_t> left_indices = {static_cast<size_t>(rank * 100),
249+
static_cast<size_t>(rank * 100 + 1)};
249250
std::vector<double> left_data = {static_cast<double>(rank * 1000),
250251
static_cast<double>(rank * 1000 + 100)};
251252
auto sparse_left = sparsevector::create<double>(left_indices, left_data);
252253

253-
std::vector<size_t> right_indices = {rank * 200, rank * 200 + 1};
254+
std::vector<size_t> right_indices = {static_cast<size_t>(rank * 200),
255+
static_cast<size_t>(rank * 200 + 1)};
254256
std::vector<double> right_data = {static_cast<double>(rank * 2000),
255257
static_cast<double>(rank * 2000 + 200)};
256258
auto sparse_right = sparsevector::create<double>(right_indices, right_data);

0 commit comments

Comments
 (0)