[Bug c/17170] New: -Wdefault-bitfield-sign
terra at gnome dot org
gcc-bugzilla@gcc.gnu.org
Tue Aug 24 15:50:00 GMT 2004
I would like to see -Wdefault-bitfield-sign turn on warnings when bitfields
are declared in ways that are likely bugs:
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. Further,
I would assume that foo's warning above would be silenced by the use of one
of
`-fsigned-bitfields'
`-funsigned-bitfields'
`-fno-signed-bitfields'
`-fno-unsigned-bitfields'
booze's warning should remain, though.
--
Summary: -Wdefault-bitfield-sign
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: terra at gnome dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17170
More information about the Gcc-bugs
mailing list