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: Laurent Vivier
Subject: Re: [PATCH 3/3] qemu-timer: reuse MIN macro in qemu_timeout_ns_to_ms
Date: Wed, 23 Oct 2019 16:58:20 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

Le 23/10/2019 à 16:51, Eric Blake a écrit :
> 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.
> 

Ok, you're right [1]

Frediano, sorry for my misleading comment.

Thanks,
Laurent

[1] and gcc agrees:

int main(void)
{
        long long l;
        int i;
        typeof(0 ? l : i) f;
        typeof(1 ? l : i) t;
}

(gdb) whatis l
type = long long
(gdb) whatis i
type = int
(gdb) whatis f
type = long long
(gdb) whatis t
type = long long



reply via email to

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