Commit c1ead85d authored by Philip Pronin's avatar Philip Pronin Committed by Facebook Github Bot

fix Expected<..., eUnion> move / copy ctor

Summary:
Consider `Expected<..., eUnion>(Expected&&)` ctor, where
`ExpectedUnion` move ctor would be called first, which is noop leaving
`which_`  uninitialized; then `MoveConstructible` ctor is executed, calling
`assignValue()`, which performs action depending on uninitialized `which_`.

Reviewed By: yfeldblum

Differential Revision: D4073199

fbshipit-source-id: 623660e7047afcebf9f72d83f91f84ff6078090f
parent 02548aa0
...@@ -249,12 +249,11 @@ struct ExpectedUnion { ...@@ -249,12 +249,11 @@ struct ExpectedUnion {
union { union {
Value value_; Value value_;
Error error_; Error error_;
char ch_; char ch_{};
}; };
Which which_; Which which_ = Which::eEmpty;
explicit constexpr ExpectedUnion(EmptyTag) noexcept explicit constexpr ExpectedUnion(EmptyTag) noexcept {}
: ch_{}, which_(Which::eEmpty) {}
template <class... Vs> template <class... Vs>
explicit constexpr ExpectedUnion(ValueTag, Vs&&... vs) noexcept( explicit constexpr ExpectedUnion(ValueTag, Vs&&... vs) noexcept(
noexcept(Value(static_cast<Vs&&>(vs)...))) noexcept(Value(static_cast<Vs&&>(vs)...)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment