Missed printf warning (%d given char)
Ross Smith
ross.s@ihug.co.nz
Thu Sep 30 19:57:00 GMT 1999
JDonner wrote:
>
> 2.95.1 (1990816) fails to detect that a %d is given a char;
> I don't know whether this is deliberate or not.
>
> const char blah[] = "abcdefgh";
> printf("%d\n", blah[5]);
This isn't a bug. In varargs functions, any integer type smaller than an
int is promoted to an int, so %d is correct for a char.
--
Ross Smith <ross.s@ihug.co.nz> The Internet Group, Auckland, New Zealand
========================================================================
"There are many technical details that make Linux attractive to the
sort of people to whom technical details are attractive." -- Suck
More information about the Gcc-bugs
mailing list