qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] block: Explicitly specify 'unsigned long long'


From: Laszlo Ersek
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

On 03/14/14 19:22, Peter Maydell wrote:
> On 14 March 2014 17:42, Laszlo Ersek <address@hidden> 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




reply via email to

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