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++/47412] New: Output: x = 31 but y = 30


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


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