qemu-trivial
[Top][All Lists]
Advanced

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

Re: [PATCH 3/3] qemu-timer: reuse MIN macro in qemu_timeout_ns_to_ms


From: Eric Blake
Subject: Re: [PATCH 3/3] qemu-timer: reuse MIN macro in qemu_timeout_ns_to_ms
Date: Wed, 23 Oct 2019 09:51:09 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

On 10/23/19 9:45 AM, Laurent Vivier wrote:

The C rules for ternary type promotion guarantee that the MIN macro
produces the correct type without the cast ('cond ? int64_t : int32_t'
produces int64_t).

gdb seems to disagree with that:

(gdb) whatis l
type = long long
(gdb) whatis i
type = int
(gdb) whatis 1 ? l : i
type = long long
(gdb) whatis 0 ? l : i
type = int

It looks like you've found a gdb bug.

C99 6.5.15 p5 states:
"If both the second and third operands have arithmetic type, the result type that would be determined by the usual arithmetic conversions, were they applied to those two operands, is the type of the result."

and the usual arithmetic conversion of 'long long OP int' is 'long long', per 6.3.1.8.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

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