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.
This commit is contained in:
Martino Pilia 2021-05-21 18:17:43 +02:00 committed by GitHub
parent fc6609276c
commit 42546176a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
{
}