[Bug c++/47412] New: Output: x = 31 but y = 30

msarshadir at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Jan 22 15:51:00 GMT 2011


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

           Summary: Output: x = 31 but y = 30
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: msarshadir@gmail.com


#include <stdio.h>

int main() {
    int x, y;

    x = 10;
    x = 20 + x++;
    printf("x = %d\n", x);

    x = 10;
    y = 20 + x++;
    printf("y = %d\n", y);

    return 0;
}

Output of above program:
       x = 31
       y = 30

x have to be 30



More information about the Gcc-bugs mailing list