On 16/06/2016 18:55, Peter Maydell wrote:
>> > Interesting, I did test clang this time. I'll fix it but really this
>> > is a compiler bug. It's *impossible* to pass a short variable
>> > argument, hence va_arg(ap, short) *must* be the same as va_arg(ap, int).
> This one's an OSX/Apple special -- it isn't part of the stock clang.
> (It has its good points -- this is the only 64-bit platform that
> will warn about format string issues that will break compile on
> 32-bit hosts.)
>
> I guess the point of the warning in this particular case is to
> say "you passed something that could be wider than a short but
> you used a format specifier which is for a short/unsigned short"
> (ie your format might be unintentionally dropping the top 16 bits
> of the data).
Does it fire even of
void f(unsigned short x)
{
printf ("%hx", x | 1);
}
?
Because technically that's an int too (and that's why I think this
particular warning is not a great thing)...
Paolo