Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: volatile Message-ID: <7876@brl-smoke.ARPA> Date: 12 May 88 14:18:56 GMT References: <20345@pyramid.pyramid.com> <833@mcdsun.UUCP> <9916@tekecs.TEK.COM> <2642@geac.UUCP> <2082@winchester.mips.COM> <2674@geac.UUCP <1030@micomvax.UUCP> <1011@ima.ISC.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB)) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 43 In article <1011@ima.ISC.COM> johnl@ima.UUCP (John R. Levine) writes: >The standard defines a language for writing portable programs, i.e. >any standard-conforming program should do the same thing on all ANSI C >processors. This simply isn't true. Since this is explained on p.4 of the draft proposed Standard, and the remarks about "volatile" are completely wrong, one has to conclude that this fellow has decided to explain the proposed Standard to you all without having understood it himself. There are two forms of Standard-conforming implementations (hosted and freestanding) and two forms of compliance for programs (conforming and strictly conforming). Conforming programs need not be at all portable; they merely need to be acceptable to a conforming implementation. In particular, conforming programs may be utterly dependent on implementation-specific features. >I have never seen any suggestion that a program containing >"volatile" would be portable except perhaps to other processors which happen >to have similar memory, I/O, and hardware architectures. The following program is strictly conforming (i.e. portable): #include main() { volatile int i; for ( i = 0; i < 10; ++i ) printf( "%d\n", i ); } It is not the use of the "volatile" type qualifier that makes a program non-portable, but rather dependence on characteristics not guaranteed by the language specification. >So, sure, go ahead and put it in your compiler where it will be useful for >all sorts of stuff. But keep it out of the standard until you can define it >in a way that will produce the same results on all C processors. The whole purpose of "volatile" is to provide a well-defined method to obtain strict virtual machine semantics, as opposed to highly- optimized "equivalent" semantics. This is obviously more nearly universal than almost anything else in the proposed Standard. How you as a programmer choose to exploit this is up to you.