Order of evalution of expressions.
Rob McMahon
cudcv at warwick.ac.uk
Wed Sep 19 20:59:34 AEST 1990
In article <6398 at castle.ed.ac.uk> elee24 at castle.ed.ac.uk (H Bruce) writes:
>Is the line
>
>value = *ptr - *ptr++;
>
>sensible C ?
>In other words is there a specified order of evaluation of expressions ?
Absolutely not, no.
>Would the following lines be optimized by a compiler (so that value is
>not loaded twice) ?
>
>value = *ptr;
>value -= *ptr++;
Well, gcc optimizes this to
ptr++;
value = 0;
I suspect your code may be wrong :-)
Rob
--
UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037
JANET: cudcv at uk.ac.warwick INET: cudcv at warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England
More information about the Comp.lang.c
mailing list