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