Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: noalias, ordinary, volatile Message-ID: <6871@brl-smoke.ARPA> Date: 18 Dec 87 22:48:59 GMT References: <8712170057.AA17035@decwrl.dec.com> <6006@j.cc.purdue.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Distribution: na Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 Keywords: noalias -> exclusive ordinary volatile In article <6006@j.cc.purdue.edu> ksb@j.cc.purdue.edu.UUCP (Kevin Braunsdorf) writes: >Think about that pointer type you should get when you have: > typedef union { > int i; > float f; > char ch; > } dummy; > /* ??? */ int *pi = & dummy.i; >Shouldn't this be volatile? How stringly should the compiler "feel" >about this? The compiler in general won't be able to tell if at run time a union is involved (consider function parameters). It is certainly unsafe to stash one type of data in a union member then use another member, and as I recall ANSI C expressly says that such use is "undefined". Again the burden is on the programmer to get it right, but then there are other, simpler, ways to try to use garbage than that, many of which the compiler can't feasibly detect in advance.