Path: utzoo!attcan!uunet!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!swrinde!ucsd!ucbvax!hplabs!hpfcso!hplisa!hplvli!boyne From: boyne@hplvli.HP.COM (Art Boyne) Newsgroups: comp.lang.c Subject: Re: Compilers and programming style (was Re: A question of style) Message-ID: <340015@hplvli.HP.COM> Date: 10 Jan 90 16:23:26 GMT References: <564@mwtech.UUCP> Organization: Loveland Inst. Div Lines: 16 scott@bbxsda.UUCP (Scott Amspoker) writes: >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? Simple: a read of the address pointed to by |p|, of whatever # of bits an int is defined as on your particular machine. The C code I write is mostly firmware built into instruments, and I have repeatedly used this construct to force a read of a hardware register, eg., to clear/disable an interrupt or other condition. Art Boyne, boyne@hplvla.hp.com