[Qemu-devel] [PATCH] target/m68k: Fix build Werror with gcc 8.0.1

Richard Henderson posted 1 patch 7 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180508185520.23757-1-richard.henderson@linaro.org
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test s390x passed
target/m68k/translate.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[Qemu-devel] [PATCH] target/m68k: Fix build Werror with gcc 8.0.1
Posted by Richard Henderson 7 years, 5 months ago
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.

Cc: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/m68k/translate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index e407ba2db3..44a0ac4e2e 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -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;
         }
-- 
2.17.0


Re: [Qemu-devel] [PATCH] target/m68k: Fix build Werror with gcc 8.0.1
Posted by Laurent Vivier 7 years, 5 months ago
Le 08/05/2018 à 20:55, Richard Henderson a écrit :
> 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.
> 
> Cc: Laurent Vivier <laurent@vivier.eu>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  target/m68k/translate.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Laurent Vivier <laurent@vivier.eu>



Re: [Qemu-devel] [PATCH] target/m68k: Fix build Werror with gcc 8.0.1
Posted by Peter Maydell 7 years, 5 months ago
On 8 May 2018 at 21:42, Laurent Vivier <laurent@vivier.eu> wrote:
> Le 08/05/2018 à 20:55, Richard Henderson a écrit :
>> 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.
>>
>> Cc: Laurent Vivier <laurent@vivier.eu>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>  target/m68k/translate.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Applied to master as a buildfix, thanks.

-- PMM