This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/30274] New: bool bit-field: wrong increment and decremenet
- From: "s__nakayama at infoseek dot jp" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Dec 2006 13:49:00 -0000
- Subject: [Bug c++/30274] New: bool bit-field: wrong increment and decremenet
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
testcase
#include <stdio.h>
#ifndef __cplusplus
typedef _Bool bool;
#endif
struct S
{
bool x: 4;
};
int main()
{
struct S x = {1};
x.x++; // x.x: value becomes 2.
printf("%d\n", x.x);
// x.x--; // accept invalid
return 0;
}
GCC 4.2 result
$g++ a.c -o a; ./a
2
GCC 4.1 result
$g++ a.c -o a; ./a
1
GCC version:4.2.0 20061212
The same bug exists also in C-frontend since 4.0.
--
Summary: bool bit-field: wrong increment and decremenet
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: s__nakayama at infoseek dot jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30274