[comp.lang.c] b[a] = ++a;

ncbauers@ndsuvax.UUCP (Michael Bauers) (12/05/87)

	Statements in C of the type b[a] = ++a or similar types of
of statements to the best of my knowledge would be implementation inde-
pendent.  It depends on whether the C compiler does all pre-increment/
decrement operations before expression evaluation, or during.  e.g.
1) Preincrement 'a', then evaluate b[a] = a...
or
2) figure out address of b[a], and then increment 'a' , and then assign 'a'
   to b[a].

Of course I may be very confused here...But this was what I think I was
told by a man who used to work for Bell Labs (i.e. implementaion dependent)

The solution is not to do this sort of thing.
It is much, much better for sanity sake to do:
++a; b[a] = a;
This way you KNOW what will happen, and you may not even cost yourself
any extra machine cycles.  The difference in speed would probably be
negligable.  Please correct me if I am wrong on this.