Compilers and programming style (was Re: A question of style)

John Hascall hascall at cs.iastate.edu
Wed Jan 10 09:06:56 AEST 1990


In article <534> scott at bbxsda.UUCP (Scott Amspoker) writes:
}In article <2283> 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?

   (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



More information about the Comp.lang.c mailing list