This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BUG report

run code below, look at i,j

int i;
int j;

i=254;
j=255;

while(1)
{
i=i++;
j=j++;
}

Parents
  • We should avoid make such illegibility.

    Illegibility has nothing to with it. This code is plain and simply illegal, as strongly as an international standardization committee without direct legal power over your home country can forbid anything at all. They go out of their way to tell you so, in the C language definition. Every C textbook worth the paper its printed on says so, too. You ignore them at your own peril.

    It should do something regular

    It can't, because there is no such thing as a "regular" behaviour in this case. That's exactly what "undefined behaviour" means. That code explicitly requests two different, contradictory behaviours from the compiler: increase i, and keep it the same. If you can't even make up your mind on what it is you want, how is the compiler supposed to be able to read your mind and do what you want?

Reply
  • We should avoid make such illegibility.

    Illegibility has nothing to with it. This code is plain and simply illegal, as strongly as an international standardization committee without direct legal power over your home country can forbid anything at all. They go out of their way to tell you so, in the C language definition. Every C textbook worth the paper its printed on says so, too. You ignore them at your own peril.

    It should do something regular

    It can't, because there is no such thing as a "regular" behaviour in this case. That's exactly what "undefined behaviour" means. That code explicitly requests two different, contradictory behaviours from the compiler: increase i, and keep it the same. If you can't even make up your mind on what it is you want, how is the compiler supposed to be able to read your mind and do what you want?

Children
No data