This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/17170] New: -Wdefault-bitfield-sign
- From: "terra at gnome dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Aug 2004 15:50:48 -0000
- Subject: [Bug c/17170] New: -Wdefault-bitfield-sign
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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