From: Daniel R. Carvalho Date: Tue, 15 Jan 2019 10:51:46 +0000 (+0100) Subject: base: Fix unitialized storage X-Git-Tag: v19.0.0.0~1252 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2c9f7ebca51eaf8fafd1f854ec0475cb18e9e20c;p=gem5.git 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 Reviewed-on: https://gem5-review.googlesource.com/c/15635 Reviewed-by: Gabe Black Maintainer: Gabe Black --- 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 bool parseParam(const std::string &s, BitUnionType &value) { - auto storage = static_cast>(value); + // Zero initialize storage to avoid leaking an uninitialized value + BitUnionBaseType storage = BitUnionBaseType(); auto res = to_number(s, storage); value = storage; return res;