Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!dino!hascall From: hascall@cs.iastate.edu (John Hascall) Newsgroups: comp.lang.c Subject: Re: Compilers and programming style (was Re: A question of style) Message-ID: <279@dino.cs.iastate.edu> Date: 9 Jan 90 22:06:56 GMT References: <1989Dec22.100135.2903@gdt.bath.ac.uk> <4367@rtech.rtech.com> <1989Dec31.153241.16479@gdt.bath.ac.uk> <649@codonics.COM> <1990Jan5.100042.26760@gdt.bath.ac.uk> <2283@dataio.Data-IO.COM> <534@bbxsda.UUCP> Sender: usenet@dino.cs.iastate.edu Organization: Iowa State Univ. Computation Center Lines: 24 In article <534> scott@bbxsda.UUCP (Scott Amspoker) writes: }In article <2283> bright@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? (using VAX-11 as an example) MOVL @P,temp ; move int pointed to by P into a throwaway or TSTL @P ; compare int pointed to by P to zero If you've never written a device driver, you may not understand why you would want to do this. Some compilers will even `help' you out by `optimizing': temp = *p; or if (*p); John Hascall / ISU Comp Ctr