Abdo said:
That is prefix increament...
This code has nothing to do with the OP code, and it's perfectly right,
google for postfix and prefix increament in C...
Thank you for being patient; i know what is post and pre increment and
so does the compiler, at least msvc6 knows this for sure, which it
implies very very clearly in the generated asm, atleast i can infer so.
I'm not imbibing asm in C but just showing how msvc6 assembler is
working after no compilation errors.
OK, I'll try to summerize: It has undefined behaviour, period.
While you can compile the OP code with any C compiler and get some
results to argue with, this can't be confirmed on all compilers, or
worse in all cases.
If this cant be confirmed on all the compilers then is that the problem
or loophole in C standard (like undefined behavior) or a bug in that
compiler? Compilers/assemblers should go in accordance with the
standard not the vice-versa. This cooresponding ASM clearly works in
accordance to standard, at least it looks to me. And i m justified in
considering asm because C is middle level language.
Just by saying that the behavior is undefined never makes it undefined.
I'm getting consistent results and the consistent opcode generation at
least for this piece of code.
I'm still wondering how can it be undefined. A piece of code, which
behaves erratic using these simple assignment, will help me to
understand it better. I should get conflicting (undefined) results for
the same equation. I've msvc6 installed on win2000.
Thanks n Regards,
Naresh