From: Richard Henderson <richard.henderson@linaro.org>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
"open list:Block layer core" <qemu-block@nongnu.org>,
crosthwaite.peter@gmail.com, quintela@redhat.com,
f4bug@amsat.org, dgilbert@redhat.com, kraxel@redhat.com,
dirty.ice.hu@gmail.com, pbonzini@redhat.com,
Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH v3] osdep: Make MIN/MAX evaluate arguments only once
Date: Wed, 3 Jun 2020 09:32:43 -0700 [thread overview]
Message-ID: <2e894b8d-a510-0689-83dc-f6c8da16410e@linaro.org> (raw)
In-Reply-To: <ecef14ce-47ca-749e-25b4-8e3ee378bd34@redhat.com>
On 6/2/20 7:29 PM, Eric Blake wrote:
> Because:
>
> #if MIN(...)
>
> now fails to compile (you can't have { in a preprocessor expression), and:
>
> #if MIN_CONST(...)
>
> fails to compile (__builtin_constant_p() is not a preprocessor macro, so it
> warns that it is being treated as 0). The only fix is to move the MIN() out of
> the #if and into the #define.
Ah, right. Thanks.
>> Is it possible to use qemu_build_not_reached?
>
> Possibly.
>
> /me goes and recompiles; touching osdep.h recompiles the world...
>
> No, it blows up hard, because qemu_build_not_reached() is not embeddable in an
> expression:
Ah, right, because without -O, qemu_build_not_reached expands to
g_assert_not_reached and not to a symbol marked with QEMU_ERROR.
>> I'd prefer we generate a compile-time error than a runtime trap (or nothing,
>> depending on compiler flags controlling __builtin_unreachable).
>
> What we have DOES produce a compile-time error. If either expression to
> MIN_CONST() is not actually const, the fact that __builtin_unreachable()
> returns void causes a compilation failure because a value is expected.
Ah! Well, that's good and certainly sufficient for my needs.
I do now wonder if it wouldn't be clearer to use "(void)0"
instead of __builtin_unreachable, and add a note to the comment just above.
r~
next prev parent reply other threads:[~2020-06-03 16:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 1:36 [PATCH v3] osdep: Make MIN/MAX evaluate arguments only once Eric Blake
2020-06-03 2:07 ` Richard Henderson
2020-06-03 2:29 ` Eric Blake
2020-06-03 15:33 ` Eric Blake
2020-06-03 16:32 ` Richard Henderson [this message]
2020-06-03 19:26 ` Eric Blake
2020-06-04 18:39 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2e894b8d-a510-0689-83dc-f6c8da16410e@linaro.org \
--to=richard.henderson@linaro.org \
--cc=crosthwaite.peter@gmail.com \
--cc=dgilbert@redhat.com \
--cc=dirty.ice.hu@gmail.com \
--cc=eblake@redhat.com \
--cc=f4bug@amsat.org \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).