From: Laszlo Ersek <lersek@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Kevin Wolf <kwolf@redhat.com>,
QEMU Developers <qemu-devel@nongnu.org>,
Jeff Cody <jcody@redhat.com>, Alexander Graf <agraf@suse.de>,
"Richard W.M. Jones" <rjones@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] block: Explicitly specify 'unsigned long long' for VHDX 64-bit constants
Date: Fri, 14 Mar 2014 19:49:29 +0100 [thread overview]
Message-ID: <53234F39.6060901@redhat.com> (raw)
In-Reply-To: <CAFEAcA-Nd7jA9wAmiYCBcvNp+DmGRwtD53xsSK3b4+x2NeiALw@mail.gmail.com>
On 03/14/14 19:22, Peter Maydell wrote:
> On 14 March 2014 17:42, Laszlo Ersek <lersek@redhat.com> wrote:
>> However, it wouldn't be an immediate, transparent change. For example,
>> out-of-range left-shifting for a signed int is explicitly undefined
>> behavior in C99 (6.5.7p4) -- equally for shifting left a negative value
>> -- and the argument has been made before that C89 does *not* say this.
>
> Does gcc *actually* change its behaviour in this area depending
> on the stanadrd specified?
There are at least two aspects to this question.
- The first aspect is: assume that there is a silent change between C89
and C99, and gcc does implement both versions of the standard
correctly. Then the silent change will affect the qemu code base.
One step in the direction of auditing this is downloading
<http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf>, and
searching it for the string QUIET CHANGE.
One good example is for 6.4.4.1 "Integer constants":
QUIET CHANGE IN C99
Unsuffixed integer constants may have different types in C99 than
in C89. Such constants greater than LONG_MAX are of type unsigned
long in C89, but are of type long long in C99 (if long long has
more range than long).
I have no clue what gnu89 does.
- The 2nd aspect is level of C99 support in gcc. We could be using a
non-C89 language feature that has worked well in gnu89 dialect since
forever. The same language feature could be broken in C99 mode on an old
gcc version.
Quickly skimming <http://gcc.gnu.org/c99status.html>, there are
C99-related fixes that are as recent as
* extended identifiers: GCC 4.1 -- we shouldn't be using those,
* integer promotion rules: GCC 4.0 -- no idea about the specifics, but
this is very important,
* inline functions: GCC 4.3 -- "Inline function support present since
at least GCC 1.21, but with major differences from C99 semantics
until 4.3."
For example, RHEL-5 ships gcc-4.1.2-55.el5 (and I gather that people
still build upstream qemu on RHEL-5). Using a c99 dialect, inline
functions could work differently between gcc-4.1 and say gcc-4.8, while
using a gnu89 dialect, there's probably no difference for inline
functions between gcc-4.1 and gcc-4.8.
I think we should ask gcc people... and go forward to gnu99, and fix
resultant bugs gradually.
Laszlo
next prev parent reply other threads:[~2014-03-14 18:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-14 10:50 [Qemu-devel] [PATCH] block: Explicitly specify 'unsigned long long' for VHDX 64-bit constants Jeff Cody
2014-03-14 15:25 ` Stefan Hajnoczi
2014-03-14 15:36 ` Richard W.M. Jones
2014-03-14 15:38 ` Peter Maydell
2014-03-14 15:57 ` Richard W.M. Jones
2014-03-14 16:26 ` Laszlo Ersek
2014-03-14 16:51 ` Richard W.M. Jones
2014-03-14 17:27 ` Laszlo Ersek
2014-03-14 17:49 ` Richard W.M. Jones
2014-03-14 18:16 ` Laszlo Ersek
2014-03-14 16:17 ` Laszlo Ersek
2014-03-14 16:26 ` Peter Maydell
2014-03-14 16:35 ` Laszlo Ersek
2014-03-14 16:36 ` Laszlo Ersek
2014-03-14 17:08 ` Peter Maydell
2014-03-14 17:42 ` Laszlo Ersek
2014-03-14 18:22 ` Peter Maydell
2014-03-14 18:49 ` Laszlo Ersek [this message]
2014-03-14 18:57 ` Laszlo Ersek
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=53234F39.6060901@redhat.com \
--to=lersek@redhat.com \
--cc=agraf@suse.de \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
--cc=stefanha@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).