From 98d1a0aab86667f8022aa2cf33fa9cd43794ae6c Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 22 May 2026 20:20:48 +0200 Subject: [PATCH] tests: suppress GCC 16 false positive -Warray-bounds warning GCC 16 emits a spurious -Warray-bounds warning when std::make_shared uses placement new into its internal control block buffer. This causes build failures in client_zero_test.cpp and mb_controller_test.cpp. Suppress the warning with #pragma GCC diagnostic around the affected std::make_shared calls, guarded by __GNUC__ >= 16 to leave older compilers unaffected. Fixes: https://github.com/EttusResearch/uhd/issues/923 --- host/tests/client_zero_test.cpp | 8 ++++++++ host/tests/mb_controller_test.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/host/tests/client_zero_test.cpp b/host/tests/client_zero_test.cpp index dedf801d9..0c5056497 100644 --- a/host/tests/client_zero_test.cpp +++ b/host/tests/client_zero_test.cpp @@ -173,7 +173,15 @@ BOOST_AUTO_TEST_CASE(simple_read_if_chdr_pkt) mock_reg_iface->add_connection(ddc1_id, 0, sep1_id, 0); constexpr size_t num_edges = 8; // Number of lines above +// GCC16 comes with a bug that produces a spurious warning here. +#if defined(__GNUC__) && __GNUC__ >= 16 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif auto mock_client0 = std::make_shared(mock_reg_iface); +#if defined(__GNUC__) && __GNUC__ >= 16 +# pragma GCC diagnostic pop +#endif BOOST_CHECK_EQUAL(mock_client0->get_proto_ver(), mock_reg_iface->GLOBAL_PROTOVER); BOOST_CHECK_EQUAL(mock_client0->get_device_type(), mock_reg_iface->DEVICE_TYPE); diff --git a/host/tests/mb_controller_test.cpp b/host/tests/mb_controller_test.cpp index 30b9f64f3..26c99cd7b 100644 --- a/host/tests/mb_controller_test.cpp +++ b/host/tests/mb_controller_test.cpp @@ -148,7 +148,15 @@ public: BOOST_AUTO_TEST_CASE(test_mb_controller) { +// GCC16 comes with a bug that produces a spurious warning here. +#if defined(__GNUC__) && __GNUC__ >= 16 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif auto mmbc = std::make_shared(); +#if defined(__GNUC__) && __GNUC__ >= 16 +# pragma GCC diagnostic pop +#endif BOOST_REQUIRE_EQUAL(mmbc->get_num_timekeepers(), 1); auto tk = mmbc->get_timekeeper(0);