Path: utzoo!mnetor!uunet!husc6!im4u!ut-sally!ghostwheel!ned From: ned@ghostwheel.UUCP (Ned Nowotny) Newsgroups: comp.lang.c Subject: Re: volatile Message-ID: <150@ghostwheel.UUCP> Date: 7 Apr 88 23:24:26 GMT References: <12578@brl-adm.ARPA> <1988Mar25.172355.348@utzoo.uucp> <18686@think.UUCP> <4217@ihlpf.ATT.COM> <10914@mimsy.UUCP> Reply-To: ned@ghostwheel.aca.mcc.com.UUCP (Ned Nowotny) Organization: MCC Database Program, Austin, Texas Lines: 24 Many people have claimed that "volatile" is necessary for a variety of applications. Every one of which has been successfully written at one time or another. Does this mean that all these signal handlers, interrupt handlers, etc. are written in assembly or some other language? I suppose it also means that those which are written in K&R C are incorrect... Uh... completely unoptimizable. (To -O or not to -O...) In fact, why is it assumed that silent optimaztion of poorly (or, perhaps, correctly) written code is desirable? Just because a compiler can be made smart enough to move a loop invariant out of a loop does not mean that it is a good idea. It makes more sense to just provide the programmer with a warning. If the code is incorrect, the programmer learns something valuable. If it is correct, the programmer may save himself (or herself) a frustrating bout of debugging. Optimizers should not do optimazations which can be expressed in the source language itself. However, if they recognize a possibly poor construct, they should warn the programmer. (At least until automatic code generators can be made better programmers than your typical Unix wizard.) -- Ned Nowotny (ned@ghostwheel.aca.mcc.com.UUCP)