From 42546176a911ff2f5dc3377722461499c478a67c Mon Sep 17 00:00:00 2001 From: Martino Pilia Date: Fri, 21 May 2021 18:17:43 +0200 Subject: [PATCH] Fix uninitialised warning in etl::optional (#381) The constructors of etl::optional with no argument or with etl::nullopt_t argument do not initalise the storage data member. When compiling with gcc with some specific optimisation levels, this can generate a -Wmaybe-uninitialized diagnostic warning. --- include/etl/optional.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/etl/optional.h b/include/etl/optional.h index 5ea0cd7b..328cabbe 100644 --- a/include/etl/optional.h +++ b/include/etl/optional.h @@ -112,7 +112,8 @@ namespace etl /// Constructor. //*************************************************************************** optional() - : valid(false) + : storage() + , valid(false) { } @@ -120,7 +121,8 @@ namespace etl /// Constructor with nullopt. //*************************************************************************** optional(etl::nullopt_t) - : valid(false) + : storage() + , valid(false) { }