This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/83294] New: int32_t & related definitions wrong with -funsigned-bitfields
- From: "bugdal at aerifal dot cx" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 05 Dec 2017 20:54:54 +0000
- Subject: [Bug c/83294] New: int32_t & related definitions wrong with -funsigned-bitfields
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83294
Bug ID: 83294
Summary: int32_t & related definitions wrong with
-funsigned-bitfields
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: bugdal at aerifal dot cx
Target Milestone: ---
The following minimal test case fails with -funsigned-bitfields:
struct { int32_t x:1 } foo;
foo.x = -1;
assert(foo.x < 0);
This is because __INT32_TYPE__, etc. are defined as plain "int" rather than
"signed int", and C specifies that, when the implementation interprets plain
int as unsigned in a bitfield context, it must also do this for typedefs (see
footnote 125 in n1570).
Presumably changing __INT32_TYPE__ and related macros to an explicit "signed
int" will fix the problem.