Widening bitfields for arguments
Joseph S. Myers
jsm28@cam.ac.uk
Wed Apr 25 10:00:00 GMT 2001
On Wed, 25 Apr 2001, Jakub Jelinek wrote:
> Hi!
Please submit these issues as PRs.
> struct foo
> {
> unsigned int a:16;
> };
>
> void bar (unsigned int);
>
> struct foo x;
>
> void baz (void)
> {
> bar (x.a);
> }
>
> gives a warning with -Wconversion unless -traditional:
> passing arg 1 of `bar' as unsigned due to prototype
> , but when I tried it on i386 and sparc64 without the
> bar prototype, the value was passed zero extended, not
> sign extended (unless a's type was changed to int). The
Yes. The integer promotions preserve value. int can represent all values
of the bitfield, so the default promotion makes it int. It's simply that
the warning is useless in this case and -Wconversion is meant to avoid
warning in such a case.
--
Joseph S. Myers
jsm28@cam.ac.uk
More information about the Gcc
mailing list