From: Paolo Bonzini <pbonzini@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel@nongnu.org, Stefan Weil <sw@weilnetz.de>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members
Date: Thu, 08 Mar 2012 19:07:31 +0100 [thread overview]
Message-ID: <4F58F563.1020107@redhat.com> (raw)
In-Reply-To: <4F58DD6F.8080907@codemonkey.ws>
Il 08/03/2012 17:25, Anthony Liguori ha scritto:
>>
>> Looks like a GCC bug where
>>
>> x = y = 0;
>>
>> is converted to
>>
>> x = (y = 0) != 0;
>
> Curious, why convert like this? What does this optimization do?
Nothing, it's just that if "y = 0" is an int (for some reason, I didn't
check if it's implicit promotion or just that y is already an int), then
it has to be converted back to a truth value before assigning to bool.
If you do
bool x;
int y;
x = y = 2;
x is actually set to 1.
Paolo
WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
Stefan Hajnoczi <stefanha@gmail.com>,
Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel@nongnu.org, Stefan Weil <sw@weilnetz.de>
Subject: Re: [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members
Date: Thu, 08 Mar 2012 19:07:31 +0100 [thread overview]
Message-ID: <4F58F563.1020107@redhat.com> (raw)
In-Reply-To: <4F58DD6F.8080907@codemonkey.ws>
Il 08/03/2012 17:25, Anthony Liguori ha scritto:
>>
>> Looks like a GCC bug where
>>
>> x = y = 0;
>>
>> is converted to
>>
>> x = (y = 0) != 0;
>
> Curious, why convert like this? What does this optimization do?
Nothing, it's just that if "y = 0" is an int (for some reason, I didn't
check if it's implicit promotion or just that y is already an int), then
it has to be converted back to a truth value before assigning to bool.
If you do
bool x;
int y;
x = y = 2;
x is actually set to 1.
Paolo
next prev parent reply other threads:[~2012-03-08 18:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-25 13:35 [Qemu-trivial] [PATCH] vnc: Fix packed boolean struct members Stefan Weil
2012-02-25 13:35 ` [Qemu-devel] " Stefan Weil
2012-03-05 13:15 ` [Qemu-trivial] " Stefan Hajnoczi
2012-03-05 13:15 ` Stefan Hajnoczi
2012-03-08 15:26 ` [Qemu-trivial] " Stefan Hajnoczi
2012-03-08 15:26 ` Stefan Hajnoczi
2012-03-08 16:08 ` [Qemu-trivial] " Paolo Bonzini
2012-03-08 16:08 ` [Qemu-devel] " Paolo Bonzini
2012-03-08 16:25 ` [Qemu-trivial] " Anthony Liguori
2012-03-08 16:25 ` Anthony Liguori
2012-03-08 18:07 ` Paolo Bonzini [this message]
2012-03-08 18:07 ` 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=4F58F563.1020107@redhat.com \
--to=pbonzini@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=sw@weilnetz.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.