Order of evalution of expressions.

Alan J Rosenthal flaps at dgp.toronto.edu
Wed Sep 19 07:35:51 AEST 1990


elee24 at castle.ed.ac.uk (H Bruce) writes:
>Is the line
>
>value = *ptr - *ptr++;
>
>sensible C ?

absolutely not.

>Would the following lines be optimized by a compiler (so that value is
>not loaded twice) ?
>
>value = *ptr;
>value -= *ptr++;

quite often, but no non-machine-specific language definition can guarantee you
that.  but they're the best.



More information about the Comp.lang.c mailing list