Skip to contentSkip to conversation

target/m68k: Fix build Werror with gcc 8.0.1

PATCH In review Richard Henderson 3 participants 3 messages May 8, 2018 – May 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/m68k: Fix build Werror with gcc 8.0.1

Fedora 28 ships with the released gcc 8.

The Werror stems from the compiler finding a path through the second switch via a missing default case in which src1 is uninitialized, and not being able to prove that the missing default case is unreachable due to the first switch.

Simplify the second switch to merge default with OS_LONG, which returns directly. This removes the unreachable path.

---
 target/m68k/translate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/m68k/translate.c +3 -2
index e407ba2db3..44a0ac4e2e 100644
@@ -2297,7 +2297,7 @@ DISAS_INSN(arith_im)
         im = tcg_const_i32(read_im32(env, s));
         break;
     default:
-       abort();
+        g_assert_not_reached();
     }
 
     if (with_SR) {
@@ -2317,7 +2317,8 @@ DISAS_INSN(arith_im)
             }
             src1 = gen_get_sr(s);
             break;
-        case OS_LONG:
+        default:
+            /* OS_LONG; others already g_assert_not_reached.  */
             disas_undef(env, s, insn);
             return;
         }
Signature · 1 line
2.17.0
Reviewed-by on v1 1/1
#1 lore raw

Le 08/05/2018 à 20:55, Richard Henderson a écrit :

Quoted 7 lines

Fedora 28 ships with the released gcc 8.

The Werror stems from the compiler finding a path through the second switch via a missing default case in which src1 is uninitialized, and not being able to prove that the missing default case is unreachable due to the first switch.

Quoted 8 lines

Simplify the second switch to merge default with OS_LONG, which returns directly. This removes the unreachable path.

---
 target/m68k/translate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
#2 lore raw
Quoted 11 lines · Laurent Vivier
Quoted 10 lines · Richard Henderson

Fedora 28 ships with the released gcc 8.

The Werror stems from the compiler finding a path through the second switch via a missing default case in which src1 is uninitialized, and not being able to prove that the missing default case is unreachable due to the first switch.

Simplify the second switch to merge default with OS_LONG, which returns directly. This removes the unreachable path.

Quoted 7 lines
Quoted 5 lines
---
 target/m68k/translate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Applied to master as a buildfix, thanks.

-- PMM