[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 4/4] target/ppc: fix warning with clang-15
From: |
Pierrick Bouvier |
Subject: |
Re: [PATCH v4 4/4] target/ppc: fix warning with clang-15 |
Date: |
Wed, 22 Feb 2023 17:02:27 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 |
On 2/22/23 00:43, Richard Henderson wrote:
On 2/21/23 12:30, Philippe Mathieu-Daudé wrote:
On 21/2/23 16:30, Pierrick Bouvier wrote:
When compiling for windows-arm64 using clang-15, it reports a sometimes
uninitialized variable. This seems to be a false positive, as a default
case guards switch expressions, preventing to return an uninitialized
value, but clang seems unhappy with assert(0) definition.
$ git grep 'assert(0)' | wc -l
96
Should we mass-update and forbid 'assert(0)' adding a check in
scripts/checkpatch.pl? Otherwise we'll keep getting similar clang
warnings...
I just think assert(0) produces a less clean error message, so on that basis
yes, we
should replace them all. Perhaps abort() as well, unless there's an
error_report
immediately preceding.
If we start exploring this way, why not define explicit noreturn
functions for this: unreachable() and todo()/unimplemented(). Names are
inspired from the same Rust macros [1]. IMHO, all assert(0) fall into
one of those two categories. It's easy to grep, and explicit.
The advantage, besides clarity, would be to guarantee it is never
removed. I noticed qemu can't be compiled with NDEBUG for now, but with
this, it would remove all assert invocations, including assert(0).
[1] https://doc.rust-lang.org/std/index.html#macros
The fact that assert(0) was seen to fall through is a system header bug. I see
we have a
workaround in include/qemu/osdep.h for __MINGW32__, but I guess this doesn't
trigger for
arm64? Pierrick, would you mind testing a change there?
I can confirm this workaround is enabled for windows-arm64.
Indeed, from msys2 clangarm64 env:
$ echo | cc -dM -E - | grep MINGW
#define __MINGW32__ 1
#define __MINGW64__ 1
$ cc --version
clang version 15.0.7
Target: aarch64-w64-windows-gnu
In more, it is needed. Without the workaround in osdep.h, compilation
fails with this message:
qemu/include/exec/exec-all.h:619:5: error: call to
qemu_build_not_reached_always declared with 'error' attribute: code path
is reachable
qemu_build_not_reached();
^
qemu/include/qemu/osdep.h:242:35: note: expanded from macro
'qemu_build_not_reached'
#define qemu_build_not_reached() qemu_build_not_reached_always()
^
1 error generated.
r~