------- Comment #11 from wilson at tuliptree dot org  2006-01-30 23:24 -------
Subject: Re:  problems with -Wformat and bit-fields

On Mon, 2006-01-23 at 16:06, tony dot luck at intel dot com wrote:
>         u64 den : 32, num : 32; /* numerator & denominator */
>         printf("den=%lx num=%lx\n", x.den, x.num);
> u.c:9: warning: format %lx expects type long unsigned int, but argument 2
> has type unsigned int

This is deliberate, as per our interpretation of the ISO C99 rules for
integer conversions.  If a bit-field has 32-bits, int is a 32-bit type,
and long is a 64-bit type, then the bit-field promotes to int/unsigned
int, even if declared with a long or unsigned long type.  If long is a
32-bit type, then the bit-field promotes to long if declared with long
type.

This is mentioned in Joseph's response in comment #2.

See also the testcase that was added for this PR.  You can click on the
testsuite link in comment #8 to see it.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22421

Reply via email to