arch: Do value-initialization for MemOperand
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Mon, 9 Dec 2019 14:00:47 +0000 (14:00 +0000)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Wed, 30 Sep 2020 08:50:39 +0000 (08:50 +0000)
With this patch we are properly initializing the MemOperand
variable, with value-initialization.
Prior to this patch, the variable was simply default-initialized.
For a native type, this means the variable is undefined.
With value initialization we are sure the variable is not undefined
and the compiler doesn't complain about it.

JIRA: https://gem5.atlassian.net/browse/GEM5-196

Change-Id: I55a5b8f047b8e691529807b61d38f0d47fcfe61e
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23526
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com>
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/arch/isa_parser.py

index 4f69a3f4a7bf9f7d2b14cb9fbfa9c8c1626c58db..86f50892ff6ee0e34c4c1a48b623047c3191964a 100755 (executable)
@@ -1076,7 +1076,7 @@ class MemOperand(Operand):
 
     def makeDecl(self):
         # Declare memory data variable.
-        return '%s %s;\n' % (self.ctype, self.base_name)
+        return '%s %s = {};\n' % (self.ctype, self.base_name)
 
     def makeRead(self, predRead):
         if self.read_code != None: