Path: utzoo!attcan!uunet!husc6!mailrus!tut.cis.ohio-state.edu!bloom-beacon!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: comp.lang.c Subject: Re: A different view of volatile Message-ID: <1100@mcgill-vision.UUCP> Date: 16 May 88 07:43:09 GMT References: <178@wyse.wyse.com> Organization: McGill University, Montreal Lines: 35 Posted: Mon May 16 03:43:09 1988 In article <178@wyse.wyse.com>, mikew@wyse.wyse.com writes: > It seems that volatile is ill-defined when combined with operators > that operate in-place. [suggestion:] [S]tate that conforming > programs can't have a volatile variable that is on boths sides of an > equal sign, volatile variables can't be used on the left hand side of > [the (op)= operators] and volatiles can't be used at all with [++ and > --]. > Example: [edited] > volatile int a; int c; > a=a; /* illegal */ > a=a+c; /* illegal */ > a+=c; /* illegal */ I would argue that none of the above are at all hazy. In each case, I would claim that the result is exactly equivalent to the result obtained by using a temporary. For example, we can consider a+=c to be identical to a=a+c (a is a simple variable, remember). So the second and third are really the same. Then, I would say that a = ; is identical to { /* not volatile */ int temp; temp = ; a = temp; } On some machines, this may mean that a+=c must compile to different code depending on whether a is volatile. (For example, the VAX addl2 instruction might not be usable, depending on exactly how it works.) der Mouse uucp: mouse@mcgill-vision.uucp arpa: mouse@larry.mcrcim.mcgill.edu