From db8e8b74cdf7b63d9baaf0d1ee949aa103dcc744 Mon Sep 17 00:00:00 2001 From: Xinli Shang Date: Tue, 30 Dec 2025 09:52:42 -0800 Subject: [PATCH] fix: make static_assert template-dependent in ByteSwap The static_assert(false, ...) in the ByteSwap function template was unconditionally evaluated at template definition time, which could cause compilation failures even when the else branch is never instantiated. Changed to static_assert(sizeof(T) == 0, ...) to make the assertion dependent on the template parameter T. This ensures the assertion only triggers when the else branch is actually instantiated with an unsupported floating-point type size. --- src/iceberg/util/endian.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/iceberg/util/endian.h b/src/iceberg/util/endian.h index 30c38baee..52fa93e67 100644 --- a/src/iceberg/util/endian.h +++ b/src/iceberg/util/endian.h @@ -48,7 +48,8 @@ constexpr T ByteSwap(T value) { } else if constexpr (sizeof(T) == sizeof(uint64_t)) { return std::bit_cast(std::byteswap(std::bit_cast(value))); } else { - static_assert(false, "Unsupported floating-point size for endian conversion."); + static_assert(sizeof(T) == 0, + "Unsupported floating-point size for endian conversion."); } } }