From 3c12be319b9d69de6790d4439cf8d3b2089c8da4 Mon Sep 17 00:00:00 2001 From: Brahmajit Das Date: Sun, 9 Nov 2025 12:37:47 +0530 Subject: [PATCH 1/2] UCS/BITMAP/TEST: Fix build with >= Clang 21 First caught on Gentoo LLVM with Clang 21.1.5 and LLVM 21.1.5 Build with fail with the following error message core/ucp_context.c:2673:47: error: default initialization of an object of type 'typeof (*tl_bitmap_super)' (aka 'const ucp_tl_bitmap_t') leaves the object uninitialized [-Werror,-Wdefault-const-init-var-unsafe] /var/tmp/portage/sys-cluster/ucx-1.19.0/work/ucx-1.19.0/src/ucs/datastruct/static_bitmap.h:250:5: note: expanded from macro 'UCS_STATIC_BITMAP_NOT' 250 | UCS_STATIC_BITMAP_UNARY_OP(_bitmap, not, UCS_PP_UNIQUE_ID) | ^ /var/tmp/portage/sys-cluster/ucx-1.19.0/work/ucx-1.19.0/src/ucs/datastruct/static_bitmap.h:239:5: note: expanded from macro 'UCS_STATIC_BITMAP_UNARY_OP' 239 | _UCS_STATIC_BITMAP_UNARY_OP(_bitmap, _op_name, _uid) | ^ /var/tmp/portage/sys-cluster/ucx-1.19.0/work/ucx-1.19.0/src/ucs/datastruct/static_bitmap.h:232:29: note: expanded from macro '_UCS_STATIC_BITMAP_UNARY_OP' 232 | ucs_typeof(_bitmap) _r_##_uid; \ | ^ :54:1: note: expanded from here 54 | _r_0 | ^ core/ucp_context.c:2672:25: error: default initialization of an object of type 'typeof (*tl_bitmap)' (aka 'const ucp_tl_bitmap_t') leaves the object uninitialized [-Werror,-Wdefault-const-init-var-unsafe] 2672 | ucp_tl_bitmap_t b = UCS_STATIC_BITMAP_AND(*tl_bitmap, | ^ The cause is probably Clang now being more strict and ucs_typeof(_bitmap) _r_##_uid being declared and not used. Signed-off-by: Brahmajit Das --- src/ucs/datastruct/static_bitmap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ucs/datastruct/static_bitmap.h b/src/ucs/datastruct/static_bitmap.h index ef2884a3be8..c505193a383 100644 --- a/src/ucs/datastruct/static_bitmap.h +++ b/src/ucs/datastruct/static_bitmap.h @@ -229,7 +229,7 @@ BEGIN_C_DECLS #define _UCS_STATIC_BITMAP_UNARY_OP(_bitmap, _op_name, _uid) \ ({ \ ucs_typeof(_bitmap) _b_##_uid = (_bitmap); \ - ucs_typeof(_bitmap) _r_##_uid; \ + ucs_typeof(_bitmap) _r_##_uid = {0}; \ \ ucs_bitmap_bits_##_op_name(UCS_STATIC_BITMAP_BITS_ARGS(&_r_##_uid), \ UCS_STATIC_BITMAP_BITS_CARGS(&_b_##_uid)); \ @@ -255,7 +255,7 @@ BEGIN_C_DECLS ({ \ ucs_typeof(_bitmap1) _b1_##_uid = (_bitmap1); \ ucs_typeof(_bitmap2) _b2_##_uid = (_bitmap2); \ - ucs_typeof(_bitmap1) _r_##_uid; \ + ucs_typeof(_bitmap1) _r_##_uid = {0}; \ \ ucs_bitmap_bits_binary_op(UCS_STATIC_BITMAP_BITS_ARGS(&_r_##_uid), \ UCS_STATIC_BITMAP_BITS_CARGS(&_b1_##_uid), \ From a950e7a9a68062806cca4b1b613d5515553c1b5e Mon Sep 17 00:00:00 2001 From: Brahmajit Das Date: Sun, 9 Nov 2025 12:42:29 +0530 Subject: [PATCH 2/2] TEST/IODEMO: Use std::shuffle when available random_shuffle was deprecated in C++14 and completely removed in C++17. With newer compilers like Clang 21, the build fails. This commit should preserve older behavior and use std::shuffle when available. Signed-off-by: Brahmajit Das --- test/apps/iodemo/io_demo.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/apps/iodemo/io_demo.cc b/test/apps/iodemo/io_demo.cc index cc696bc6b23..abd50ddbdf4 100644 --- a/test/apps/iodemo/io_demo.cc +++ b/test/apps/iodemo/io_demo.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -2998,9 +2999,17 @@ static int do_client(options_t& test_opts) IoDemoRandom::srand(test_opts.random_seed); LOG << "random seed: " << test_opts.random_seed; - // randomize servers to optimize startup + // randomize servers to optimize startup (handle C++17+) +#if __cplusplus >= 201703L + // std::shuffle replaces std::random_shuffle in C++17 + std::random_device rd; + std::mt19937 rng(rd()); + std::shuffle(test_opts.servers.begin(), test_opts.servers.end(), rng); +#else + // For older C++ standards, keep std::random_shuffle std::random_shuffle(test_opts.servers.begin(), test_opts.servers.end(), IoDemoRandom::urand); +#endif UcxLog vlog(LOG_PREFIX, test_opts.verbose); vlog << "List of servers:";