mirror of https://github.com/PentHertz/srsLTE.git
Fix the default constructor of the optional class to avoid a spurious uninitialized value warning in older GCC versions (seen for ARM32 and GCC 8.3).
Use a union of a byte and the real storage, and init the char by default.
This commit is contained in:
parent
485ec2edab
commit
cf20b143c0
|
@ -24,7 +24,7 @@ class optional
|
|||
public:
|
||||
using value_type = T;
|
||||
|
||||
optional() : has_val_(false) {}
|
||||
optional() : has_val_(false), empty() {}
|
||||
optional(const T& t) : has_val_(true) { storage.emplace(t); }
|
||||
optional(T&& t) : has_val_(true) { storage.emplace(std::move(t)); }
|
||||
optional(const optional<T>& other) : has_val_(other.has_value())
|
||||
|
@ -98,8 +98,11 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
bool has_val_;
|
||||
detail::type_storage<T> storage;
|
||||
bool has_val_;
|
||||
union {
|
||||
char empty;
|
||||
detail::type_storage<T> storage;
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
Loading…
Reference in New Issue