qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] tcg: Fix complilation with TCG


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] tcg: Fix complilation with TCG
Date: Wed, 22 Nov 2017 12:14:49 +0000

On 22 November 2017 at 12:08, Richard Henderson
<address@hidden> wrote:
> On 11/22/2017 01:03 PM, Peter Maydell wrote:
>> Wow, I totally do not expect "assert(tcg_enabled())" to mean
>> "we rely on the compiler to be able to determine that this
>> code is dead" (and in general I'm not a fan of the compilation
>> relying on the compiler determining that code is dead).
>
> We do this all of the time for more regular tests that are obviously
> compile-time.  I am a really big fan of this, because it makes sure that the
> (usually 32-bit) else branch continues to compile.

I'm happy with code that is "we assume the compiler is going to
be sensible here so we don't have to use #ifdefs in the name
of performance". I just don't think we should write code that
can't compile at all if the compiler happens to not identify
the codepath as dead. There's no guarantee by the compiler
that it's going to do that.

Also, if we do have some need to do this, assert() is the
wrong way to do it -- the program should behave (and build)
identically if you strip all the assert()s out of it.
We should have some construct that makes the intent clear.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]