Compilers and programming style (was Re: A question of style)
P E Smee
exspes at gdr.bath.ac.uk
Wed Jan 10 22:48:49 AEST 1990
In article <534 at bbxsda.UUCP> scott at bbxsda.UUCP (Scott Amspoker) writes:
>In article <2283 at dataio.Data-IO.COM> bright at dataio.Data-IO.COM (Walter Bright) writes:
>>volatile int *p;
>>*p; /* has side effects and must not be optimized away */
>
>Just curious - what kind of code should be generated for the above
>C fragment?
Precisely the same code as if you had written:
pp = *p; /* pp of a suitably sensible data type */
except that it doesn't have to include the final store into a memory location.
More complicatedly, anything the compiler writer likes which has the
same side effects as would have occurred if the value of *p had then
been used. (If on a particular machine, the answer is provably
guaranteed always to be 'none at all', then the statement *could* be
optimized out by compilers specific to that machine.)
--
Paul Smee, Univ of Bristol Comp Centre, Bristol BS8 1TW, Tel +44 272 303132
Smee at bristol.ac.uk :-) (..!uunet!ukc!gdr.bath.ac.uk!exspes if you MUST)
More information about the Comp.lang.c
mailing list