At 18:33 13/05/2005 -0400, you wrote:
Now, tell me
what will be printed:
int i = 0;
i = i++;
printf("%d\n", i);
Whatever the implementation feels like giving you.
EXACTLY! - that is the only truly correct answer.
Expected/likely answers are 0 and/or 1 ... but this is NOT
guaranteed by the standard.
Again, i is being modified multiple times between
sequence points, so
it's nasal demon time.
Although the nasal demon theory has been around for a long time, I
am certain that this will not be the result here - not of my machines
are fitted with appropriate I/O hardware to cause this - but as was
pointed out many years ago - it COULD be the result!
Yes - this is essentually the same scenario - I just removed any
doubt caused by order of execution of function parameters - this is
an example of prime undefined behaviour.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML mouse at rodents.montreal.qc.ca
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
PS: Sorry to be so brief on the phone (family movie in progress)...
see you on sunday.
Dave
--
dave04a (at) Dave Dunfield
dunfield (dot) Firmware development services & tools:
www.dunfield.com
com Collector of vintage computing equipment:
http://www.parse.com/~ddunfield/museum/index.html