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++/29295] New: ++ operator with bool typedef increments


This program:

extern "C" void abort();
typedef bool my_bool;
int main()
{ 
  my_bool b = false;
  int i;

  b++;
  b++;
  i = b;
  if (i != 1)
    abort ();
  return 0;
}

calls abort(), because GCC is generating an increment for the '++' operator
rather than setting the value to true, and so 'i' becomes 2 not 1.


-- 
           Summary: ++ operator with bool typedef increments
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: geoffk at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29295


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