From f94e4a30ac9e7afa9d52d67b06c3a7cf31f9d5a5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 27 Nov 2025 18:41:36 -0600 Subject: [PATCH] safer --- esphome/core/automation.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/core/automation.h b/esphome/core/automation.h index 298bb80569..61d2944acf 100644 --- a/esphome/core/automation.h +++ b/esphome/core/automation.h @@ -133,10 +133,12 @@ template class TemplatableValue { case VALUE: return this->value_; case STATIC_STRING: + // if constexpr required: code must compile for all T, but STATIC_STRING + // can only be set when T is std::string (enforced by constructor constraint) if constexpr (std::same_as) { - return std::string(this->static_str_); // Convert to string only when needed + return std::string(this->static_str_); } - [[fallthrough]]; + __builtin_unreachable(); case NONE: default: return T{};