-Wdefault-bitfield-sign

Morten Welinder terra@gnome.org
Fri Aug 20 21:07:00 GMT 2004


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



More information about the Gcc mailing list