This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Widening bitfields for arguments
- To: Jakub Jelinek <jakub at redhat dot com>
- Subject: Re: Widening bitfields for arguments
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Wed, 25 Apr 2001 18:00:04 +0100 (BST)
- cc: <gcc at gcc dot gnu dot org>
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