Path: utzoo!mnetor!uunet!husc6!bloom-beacon!mit-eddie!ll-xn!ames!pacbell!att-ih!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704a-Liber) Newsgroups: comp.lang.c Subject: Re: A different view of volatile Message-ID: <4651@ihlpf.ATT.COM> Date: 5 May 88 17:09:21 GMT References: <178@wyse.wyse.com> Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 38 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. A way of alleviating this problem would >be to state 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 following >operators: +=, -=, *=, /=, |=, &=, and volatiles can't be used at all >with the following operators: ++, --. I was going to propose this myself!! I have a problem with one of your examples, though. >volatile int a,b; >a=b; /* legal */ This type of assignment should be illegal, since >a=a; /* illegal */ is illegal. Suppose the declaration was: int foo(bar1, bar2) volatile int *bar1, *bar2; *bar1 = *bar2; There may be no way, with static checking, to determine if bar1 and bar2 are the same or different. At most one variable of type volatile is allowed to appear in any statement (except for function arguments). Also, volatile variables should probably be limited to types which only require one machine instruction to load them, such as char, int, and *void (ie, structs should not be allowed to be declared volatile), and arrays made up of these types. -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_