run code below, look at i,j int i; int j; i=254; j=255; while(1) { i=i++; j=j++; }
Thank your information, I totally agree the statement like i=i++ is meaningless or something, We should avoid make such illegibility. But I think the compiler is not a judge, It should do something regular, Look at result of i and j in the KEIL is totally different. I test this code in Micorsoft C++ 6.0, Its behaviour is regular. Maybe the KEIL can do a little bit better.
We're all just a bunch of hacks here. Since you are comparing compilers' behavior for those statements, post your question to Usenet's comp.lang.c newsgroup. The people you can believe hang out there for the sole purpose of discussing Standard C and will be happy to entertain your notions of how standard compilers should handle the statements.
I can't believe I read the whole thread and wasted two minutes of my life.
"I totally agree the statement like i=i++ is meaningless or something" Please go and read the other thread - it's all been discussed before! In particular, see: http://www.eskimo.com/~scs/C-faq/q3.3.html And understand the meaning of Undefined behaviour: http://www.eskimo.com/~scs/C-faq/q11.33.html "I test this code in Micorsoft C++ 6.0, Its behaviour is regular." Nonsense - see above!
"The people you can believe hang out there for the sole purpose of discussing Standard C and will be happy to entertain your notions of how standard compilers should handle the statements." That should be worth watching...! ;-)
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?
"I can't believe I read the whole thread and wasted two minutes of my life." If you were concerned about wasting your time, you would have stopped after reading the original post. ;-)