From f9714055cd5bfbf8ad483cf9e45dfac381222b87 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Feb 2026 18:25:41 +0000 Subject: [PATCH 1/3] Initial plan From b7294533e92667a9f4561ed1eb6fc819a5e933fb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Feb 2026 18:27:50 +0000 Subject: [PATCH 2/3] fix: use __has_warning instead of HAS_ARRAY_BOUNDS to suppress -Warray-bounds in MLAS The HAS_ARRAY_BOUNDS macro is defined in onnxruntime_config.h which is never included by the MLAS compilation unit. Replace with clang's built-in __has_warning("-Warray-bounds") so the pragma actually takes effect and suppresses the false positive array-bounds error on clang 17+. Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com> --- .../core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onnxruntime/core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h b/onnxruntime/core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h index a745dd9f1376d..6b1fec97ea3d4 100644 --- a/onnxruntime/core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h +++ b/onnxruntime/core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h @@ -1670,12 +1670,12 @@ MlasQ4Int8TileGemmKernelBlkLen32Avx2( // .../onnxruntime/core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h:1531:13: note: array 'acc' declared here // 1531 | __m256 acc[NCols4]; // | ^ -#if defined(__clang__) && defined(HAS_ARRAY_BOUNDS) +#if defined(__clang__) && __has_warning("-Warray-bounds") #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warray-bounds" #endif __m128 acc_1 = FoldAccumulators(acc[4], acc[5], acc[6], acc[7]); -#if defined(__clang__) && defined(HAS_ARRAY_BOUNDS) +#if defined(__clang__) && __has_warning("-Warray-bounds") #pragma clang diagnostic pop #endif if (BiasPtr != nullptr) { From 2e038f49c99c0a4b5a049e730228b97c165b7745 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 28 Feb 2026 23:35:51 +0000 Subject: [PATCH 3/3] fix: use #ifdef __clang__ instead of __has_warning to avoid GCC preprocessor error __has_warning is a clang-specific built-in that GCC doesn't recognize. The C preprocessor doesn't short-circuit &&, so GCC fails to parse the expression even with defined(__clang__) guarding it. Since -Warray-bounds is universally supported by all clang versions, a simple #ifdef __clang__ is sufficient. Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com> --- .../core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onnxruntime/core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h b/onnxruntime/core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h index 6b1fec97ea3d4..77aa460c72ef7 100644 --- a/onnxruntime/core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h +++ b/onnxruntime/core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h @@ -1670,12 +1670,12 @@ MlasQ4Int8TileGemmKernelBlkLen32Avx2( // .../onnxruntime/core/mlas/lib/sqnbitgemm_kernel_avx2_int8_blklen32.h:1531:13: note: array 'acc' declared here // 1531 | __m256 acc[NCols4]; // | ^ -#if defined(__clang__) && __has_warning("-Warray-bounds") +#ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warray-bounds" #endif __m128 acc_1 = FoldAccumulators(acc[4], acc[5], acc[6], acc[7]); -#if defined(__clang__) && __has_warning("-Warray-bounds") +#ifdef __clang__ #pragma clang diagnostic pop #endif if (BiasPtr != nullptr) {