Skip to content

Commit

Permalink
Try to fix "uninitialized" error
Browse files Browse the repository at this point in the history
  • Loading branch information
sherman-the-tank committed Dec 23, 2021
1 parent 058a350 commit 9606182
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ jobs:
esac
- name: Make
run: |
ccache -C
ccache -z
cmake --build build/ -j $(nproc)
ccache -s
Expand Down
6 changes: 5 additions & 1 deletion src/common/base/StatusOr.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,19 @@ class StatusOr final {

void resetValue() {
destructValue();
new (&variant_) Variant();
state_ = kVoid;
}

void resetStatus() {
destructStatus();
new (&variant_) Variant();
state_ = kVoid;
}

void destruct() {
if (isVoid()) {
destructStatus();
return;
}
if (hasValue()) {
Expand All @@ -311,13 +314,14 @@ class StatusOr final {

void reset() {
destruct();
new (&variant_) Variant();
state_ = kVoid;
}

private:
// Variant type to hold a `Status', or a `T', or nothing
union Variant {
Variant() {}
Variant() : status_(Status()) {}
Variant(const Status &status) : status_(status) {}
Variant(Status &&status) : status_(std::move(status)) {}
template <typename U, typename = std::enable_if_t<is_initializable_v<U>>>
Expand Down

0 comments on commit 9606182

Please sign in to comment.