From f677a1d49210ac30b391ca349886b5333e31c004 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 30 Apr 2026 14:56:37 +0200 Subject: [PATCH] Fix compiler warnings from actual sanitizer use --- include/etl/private/delegate_cpp11.h | 8 ++++++++ test/test_bsd_checksum.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/etl/private/delegate_cpp11.h b/include/etl/private/delegate_cpp11.h index 9664797b..27b443c0 100644 --- a/include/etl/private/delegate_cpp11.h +++ b/include/etl/private/delegate_cpp11.h @@ -566,6 +566,14 @@ namespace etl //************************************************************************* ETL_NODISCARD ETL_CONSTEXPR14 bool is_valid() const ETL_NOEXCEPT { + // GCC's UBSan instruments function pointer comparisons, which prevents + // constexpr evaluation. Use implicit bool conversion at compile time + // to avoid the instrumented != comparison while still checking validity. + if (etl::is_constant_evaluated()) + { + return static_cast(invocation.stub); + } + return invocation.stub != ETL_NULLPTR; } diff --git a/test/test_bsd_checksum.cpp b/test/test_bsd_checksum.cpp index 9274b112..f95dcf12 100644 --- a/test/test_bsd_checksum.cpp +++ b/test/test_bsd_checksum.cpp @@ -50,7 +50,7 @@ namespace for (size_t i = 0UL; i < sizeof(value_type); ++i) { - uint8_t byte = static_cast((static_cast(value) >> (i * 8UL)) & 0xFFU); + uint8_t byte = static_cast((static_cast(value) >> (i * 8U)) & 0xFFU); checksum = etl::rotate_right(checksum) + byte; } }