From 30e6e0a6b7cfbd16532ad74bf6aa4f7ac6361ead Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 15 Mar 2026 22:41:15 -1000 Subject: [PATCH] [core] Add static_assert for void* / uintptr_t size parity Ensures the inline Callback storage path is only used on platforms where void* has no trap representations (all bit patterns valid). --- esphome/core/helpers.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index efba3aa56ed..a8957db0b57 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -1737,6 +1737,10 @@ constexpr float fahrenheit_to_celsius(float value) { return (value - 32.0f) / 1. template struct Callback; template struct Callback { + // The inline storage path stores callable bytes in ctx via memcpy. + // This requires all bit patterns to be valid for void* (no trap representations). + static_assert(sizeof(void *) == sizeof(std::uintptr_t), "void* must be the same size as uintptr_t"); + void (*fn)(void *, Ts...); void *ctx;