diff options
author | Daniel R. Carvalho <odanrc@yahoo.com.br> | 2019-01-15 11:51:46 +0100 |
---|---|---|
committer | Daniel Carvalho <odanrc@yahoo.com.br> | 2019-01-18 12:46:31 +0000 |
commit | 2c9f7ebca51eaf8fafd1f854ec0475cb18e9e20c (patch) | |
tree | 9675809fabed19e48a28ddddb3889cfb28fcce42 /src | |
parent | 5dda7fb959682f9e051a12de15b982f03adbc1fb (diff) | |
download | gem5-2c9f7ebca51eaf8fafd1f854ec0475cb18e9e20c.tar.xz |
base: Fix unitialized storage
The bitunion is not being initialized on constructor to avoid
performance overhead, and that generated a maybe-unitialized
error when a sub-class was being copied before assigned in
serialize's parseParam() in some compilers.
This patch adds zero-initialization to the problematic variable
to appease the compiler.
Change-Id: I90fa6aa356b3e14ec25e3294b17ed10f429a9a38
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/15635
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/sim/serialize.hh | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh index 543477726..a45d1bbcd 100644 --- a/src/sim/serialize.hh +++ b/src/sim/serialize.hh @@ -289,7 +289,8 @@ template <class T> bool parseParam(const std::string &s, BitUnionType<T> &value) { - auto storage = static_cast<BitUnionBaseType<T>>(value); + // Zero initialize storage to avoid leaking an uninitialized value + BitUnionBaseType<T> storage = BitUnionBaseType<T>(); auto res = to_number(s, storage); value = storage; return res; |