mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 17:48:40 +00:00
[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).
This commit is contained in:
@@ -1737,6 +1737,10 @@ constexpr float fahrenheit_to_celsius(float value) { return (value - 32.0f) / 1.
|
||||
template<typename... X> struct Callback;
|
||||
|
||||
template<typename... Ts> struct Callback<void(Ts...)> {
|
||||
// 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user