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
This commit is contained in:
Martin Braun 2026-05-22 20:20:48 +02:00
parent 1b0c95e31a
commit 98d1a0aab8
2 changed files with 16 additions and 0 deletions

View File

@ -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<uhd::rfnoc::detail::client_zero>(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);

View File

@ -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<mock_mb_controller>();
#if defined(__GNUC__) && __GNUC__ >= 16
# pragma GCC diagnostic pop
#endif
BOOST_REQUIRE_EQUAL(mmbc->get_num_timekeepers(), 1);
auto tk = mmbc->get_timekeeper(0);