This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
-Wdefault-bitfield-sign
- From: terra at gnome dot org (Morten Welinder)
- To: gcc at gcc dot gnu dot org
- Date: Fri, 20 Aug 2004 13:30:47 -0400 (EDT)
- Subject: -Wdefault-bitfield-sign
While the warning-wishlists are being thrown around I would like to
toss in a few:
struct oink {
int foo : 5; // warning: the signedness of foo is implementation defined
signed int bar : 5; // no warning
int : 5; // no warning (since no name)
int booze : 1; // warning: dubious signed one-bit bitfield
signed int baz : 1; // no warning.
};
(A signed bitfield on width one can contain {-1;0} or {0} depending on integer
representation. The latter allows for impressive optimizations, but surely
someone meant to use unsigned.)
Adding "signed" or "unsigned" as shown would silence the warnings.
Morten