From 4177717a94bc25aa4f6f5b1e625c09496b64e9cb Mon Sep 17 00:00:00 2001 From: Alexey Bader Date: Thu, 18 Dec 2025 14:12:01 -0800 Subject: [PATCH] Value-initialize marray to avoid undefined behavior. sycl::marray default constructor check has undefined behavior. marray is default-initialized, which means that elements of marray is also default-initialized. For element data type like `int` default-initialized value with automatic storage produces indeterminate value. The check compares marray elements with value-initialized object (i.e. with `0` for `int` data type). Using indetermiate values in compare operation causes undefined behavior. The issue is exposed by recent change in DPC++ implementation, which switched marray elements initialization in default constructor from value-initialization to default-initialization. https://github.com/intel/llvm/commit/ba4f090bff414537ee4f7c91ed15fcc70ba12739 See https://en.cppreference.com/w/cpp/language/default_initialization.html for more details. --- tests/marray_basic/marray_constructor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/marray_basic/marray_constructor.h b/tests/marray_basic/marray_constructor.h index dfd4157d8..b83665085 100644 --- a/tests/marray_basic/marray_constructor.h +++ b/tests/marray_basic/marray_constructor.h @@ -48,7 +48,7 @@ class run_marray_constructor_test { static void run_checks(IteratorT results) { // default constructor { - marray_t ma; + marray_t ma{}; *(results++) = value_operations::are_equal(ma, DataT{}); }