3 ms·
In Java, it seems to work, but in C (gcc 4.6.3) it doesn't. a ends up unchanged, since the first instance of b contains the original value of a when evaluated.
by dbush 14y ago
In Java, it seems to work, but in C (gcc 4.6.3) it doesn't. a ends up unchanged, since the first instance of b contains the original value of a when evaluated. Not sure why Java evaluates it the way it does.
- emn13 14y agoThat's because java is much stricter about enforcing the order of evaluation in these kinds of aliased statements, whereas in C it's undefined and the compiler just "does something". Of course, you'd have to be a real code-masochist to do this to yourself even in java...