base: change bitunion default constructor to default

Current implementation prevents customers from performing zero
initialize on BitUnion class. Customers would get unexpected results
when writing `BitUnion{}`. Changing the default constructor to default
can solve this issue.

After changing the default constructor, the test failed with unused
variable. I also change one with zero initializer and make the other
with maybe_unused label.
```
tests/build/ARM/base/bitunion.test.cc:133:14: error: 'emptySixteen' defined but not used [-Werror=unused-variable]
  133 | EmptySixteen emptySixteen;
      |              ^~~~~~~~~~~~
tests/build/ARM/base/bitunion.test.cc:132:16: error: 'emptyThirtyTwo' defined but not used [-Werror=unused-variable]
  132 | EmptyThirtyTwo emptyThirtyTwo;
      |                ^~~~~~~~~~~~~~
```

Change-Id: Icbed36b3fa6751cbda63e84443eaab6d865d9bd6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/57730
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Yu-hsin Wang
2022-03-16 11:49:02 +08:00
parent e1714d7833
commit 2ced661aed
2 changed files with 3 additions and 3 deletions

View File

@@ -261,7 +261,7 @@ namespace bitfield_backend
BitUnionOperators(const BitUnionOperators &) = default;
BitUnionOperators() {}
BitUnionOperators() = default;
//Conversion operators.
operator const typename Base::__StorageType () const

View File

@@ -129,8 +129,8 @@ containingFunc(uint64_t init_val, uint64_t fieldVal)
// Declare these as global so g++ doesn't ignore them. Initialize them in
// various ways.
EmptySixtyFour emptySixtyFour = 0;
EmptyThirtyTwo emptyThirtyTwo;
EmptySixteen emptySixteen;
EmptyThirtyTwo emptyThirtyTwo{};
[[maybe_unused]] EmptySixteen emptySixteen;
EmptyEight emptyEight(0);
class BitUnionData : public testing::Test