Undefined behaviour:
s=++a + ++a;
Anything can happen when undefined, so your behaviour is perfectly valid.
Secure
2010-08-17 09:04:46
Undefined behaviour:
s=++a + ++a;
Anything can happen when undefined, so your behaviour is perfectly valid.
I'd suspect this is an artifact of compiler optimisation, in the first example a
is known so the compiler optimises the preincrements to occur before the addition. In the second example the value is unknown and the compiler does not optimise the sequence causing it to complete left to right. This may be a function of your specific compiler and it would need to be looked at specifically.
Undefined behaviour. Change it, or you risk being attacked by raptors.