This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/30274] New: bool bit-field: wrong increment and decremenet


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]