[cfe-dev] warning with conditional operator and printf, is this a bug ?

Pasi Parviainen pasi.parviainen at iki.fi
Fri Nov 4 18:37:51 PDT 2011


On 5.11.2011 1:26, David Blaikie wrote:
>> 1) There is no a reason to do any arithmetic conversions to the
>> second or third operand of the conditional operator in this case.
>> So the result of both operands should be original type, which is
>> unit16_t for both operands.
>
> Sorry, this is the bit I don't follow. "the usual arithmetic
> conversion" isn't something that requires a "reason" it's a thing of
> its own. I quoted it in my original reply, but applying "the usual
> arithmetic conversion" to "uint16_t" should result in "int", unless
> I'm missing something.

Well, in this case you are missing that the ellipsis notation doesn't
expect any kind of type for its arguments, and hence there's no need to 
do any type conversion for results of those expressions.

Those expressions may disagree about the resulting type between each 
other or with the expected type of printf and that should be warned, but 
that's not the case here as both resulting types and printf do agree here.

Pasi.



More information about the cfe-dev mailing list