From 52502734fa80d8ed618746d9d40c3c53806fe445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Sun, 26 Jul 2026 10:21:53 +0200 Subject: [PATCH] Fix ODR violation in optional (#1522) * Fix ODR violation in optional Detected by GCC 15, when using in a module context. * Make etl::nullopt constant --- include/etl/optional.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/etl/optional.h b/include/etl/optional.h index 371c9f2a..eeb4b5c7 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -59,7 +59,7 @@ namespace etl // Convertible to any type of null non-member pointer. template - operator T*() const + ETL_CONSTEXPR operator T*() const ETL_NOEXCEPT { return 0; } @@ -74,7 +74,7 @@ namespace etl /// A null option. ///\ingroup utilities //***************************************************************************** - const nullopt_t nullopt = {}; + ETL_INLINE_VAR ETL_CONSTANT nullopt_t nullopt = {}; //*************************************************************************** /// Exception for optional.