Path: utzoo!attcan!telly!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.lang.c Subject: Re: Order of evalution of expressions. Message-ID: <1990Sep20.015810.29674@druid.uucp> Date: 20 Sep 90 01:58:10 GMT References: <6398@castle.ed.ac.uk> Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 31 In article <6398@castle.ed.ac.uk> elee24@castle.ed.ac.uk (H Bruce) writes: >I have lost my FAQ files but I'm certain this is not on it.... >Is the line >value = *ptr - *ptr++; >sensible C ? > ... >If not what is the fastest way of computing this type of expression ? >Would the following lines be optimized by a compiler (so that value is >not loaded twice) ? > >value = *ptr; >value -= *ptr++; Why not: value = 0; ptr++; I suppose you meant: value = *ptr; value -= *(++ptr); or value = *ptr++; value -= *ptr; In any case, the order of evaluation is undefined (K&R2 pp 53) so you you need two statements. -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | MS-DOS: The Andrew Dice Clay West Hill, Ontario, Canada | of operating systems. + 416 281 6094 |