Possible Duplicate:
Undefined Behavior and Sequence Points
I am having trouble in understanding the following macro:
#define CUBE(x) ((x)*(x)*(x))
My code:
int y=5;
print("Cube = %d",CUBE(++y));
This piece of code prints 512 (Using Microsoft Visual Studio)
I was expecting this to print: ((++5)*(++6)*(++7)) = (6*7*8) = 336
.
How this is evaluated?
Also the same code was compiled using Dev C++ compiler and the result is 392!!!
Can someone explain why two compilers show different results for exactly same code?
How is this ++y
evaluated?