run code below, look at i,j int i; int j; i=254; j=255; while(1) { i=i++; j=j++; }
Nobody will take your bug report seriously unless you state what results you expect for i,j values. Of course you could just be attempting to make a joke.
OK,I make clear! for C language we all know i=i++ will keep value(don't change value of i). but for code above i will keep value, j will change.
"i=i++ will keep value (don't change value of i)" Why? I'm sure we've had this one before - it's just an abuse of the post-increment operator.
"I'm sure we've had this one before" Found it: http://www.keil.com/forum/docs/thread534.asp
See the second paragraph of this article: http://cm.bell-labs.com/cm/cs/tpop/debugging.html
we all know i=i++ will keep value(don't change value of i) No, we don't all know that. Instead (or so I hope) we all know that this is a guaranteed bug in your program. That statement invokes undefined behaviour. That's about the worst type of problem a C source can have, and still make it through the compiler. Whichever source of information you drew the above conclusion from --- throw it away.
"I need a new keyboard, I does not spell correctly" same thing One thing you will find, even in the most expensive C compilers is that C is so that nobody can write a compiler that catch every dumb thing you can invent. There is a perfectly good statement: i++; why try to mutilate it by writing i-i++; If your purpose in life is to create, rather than solve problems, keep on trucking, if not stick to the ANSI standard (and the '51 extensions) Erik
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. ;-)