Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: comma operator Message-ID: <10293@mimsy.UUCP> Date: 22 Jan 88 03:45:05 GMT References: <3819@sigi.Colorado.EDU> <8599@ism780c.UUCP> <1866@bsu-cs.UUCP> <4037@june.cs.washington.edu> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 30 [One-line summary: some people are suffering from the illusion that `;' allows optimisations that `,' does not.] In article <4037@june.cs.washington.edu> pardo@june.cs.washington.edu (David Keppel) provides the following example: > int *ctrl_p = DISK_CTRL_REGISTER; > int *out_p = DISK_OUT_REGISTER; > > *ctrl_p = SETUP, *out_p = GO; > >which _relies_ on the evaluation order being guaranteed in a >stronger way than is provided by sequence points. Yes. However, the same code written this way: *ctlr_p = SETUP; *out_p = GO; *also* depends on order in a stronger way than is provided by sequence points. The *only* way to guarantee proper operation under dpANS rules is to write volatile int *ctlr_p = DISK_CTRL_REGISTER; volatile int *out_p = DISK_OUT_REGISTER; and in such a case the compiler is required to generate equivalently ordered code for either version (`,' or `;'). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris