Initialize 'imm' on opcodes/aarch64-opc.c:expand_fp_imm (and fix breakage on mingw)
authorSergio Durigan Junior <sergiodj@redhat.com>
Thu, 21 Sep 2017 15:46:48 +0000 (11:46 -0400)
committerSergio Durigan Junior <sergiodj@redhat.com>
Mon, 25 Sep 2017 05:46:23 +0000 (01:46 -0400)
Hi,

While compiling GDB using a mingw compiler from Fedora 26:

  ../gdb/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 \
    --disable-binutils --disable-ld --disable-gold --disable-gas --disable-sim \
    --disable-gprof  --enable-targets=all

I stumbled upon a simple occurrence of -Werror=maybe-uninitialized:

  ../../gdb/opcodes/aarch64-opc.c: In function 'expand_fp_imm':
  ../../gdb/opcodes/aarch64-opc.c:2880:10: error: 'imm' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     return imm;
    ^~~

It is the compiler's fault, because this function always assigns to
'imm' if the necessary conditions are met, and it calls "assert (0)"
otherwise, but I thought it'd be clearer to have 'imm' explicitly set
to zero anyway.

opcodes/ChangeLog:
2017-09-21  Sergio Durigan Junior  <sergiodj@redhat.com>

* aarch64-opc.c (expand_fp_imm): Initialize 'imm'.

opcodes/ChangeLog
opcodes/aarch64-opc.c

index 4974791184ab925809042d0b55604eb48c724152..082d7554ecffe447f2cad86619e9cae28b7326c9 100644 (file)
@@ -1,3 +1,7 @@
+2017-09-21  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * aarch64-opc.c (expand_fp_imm): Initialize 'imm'.
+
 2017-09-09  Kamil Rytarowski  <n54@gmx.com>
 
        * nds32-asm.c: Rename __BIT() to N32_BIT().
index 27c1d0908076a7548669dfbb4b4265060a78b320..c93a90ac64405e055ed6421ede850e62dc5c5aab 100644 (file)
@@ -2847,7 +2847,7 @@ typedef union
 static uint64_t
 expand_fp_imm (int size, uint32_t imm8)
 {
-  uint64_t imm;
+  uint64_t imm = 0;
   uint32_t imm8_7, imm8_6_0, imm8_6, imm8_6_repl4;
 
   imm8_7 = (imm8 >> 7) & 0x01; /* imm8<7>   */
This page took 0.028495 seconds and 4 git commands to generate.