Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Rod Pemberton Newsgroups: comp.lang.forth Subject: Re: Average swaps per word? Date: Mon, 14 Nov 2016 16:39:48 -0500 Organization: Aioe.org NNTP Server Lines: 28 Message-ID: <20161114163948.63e4da69@_> References: <5352ea02-4942-40bf-8c92-e5012aae1807@googlegroups.com> <2016Nov12.132348@mips.complang.tuwien.ac.at> <2016Nov13.155518@mips.complang.tuwien.ac.at> <871syff9mv.fsf@nightsong.com> <2016Nov14.184256@mips.complang.tuwien.ac.at> NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Newsreader: Claws Mail 3.13.1 (GTK+ 2.24.13; x86_64-unknown-linux-gnu) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:52633 On Mon, 14 Nov 2016 17:42:56 GMT anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote: > Paul Rubin writes: > >albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) writes: > >>>and gcc therefore "optimized" the memset() away. And > >>>while the following read from that memory (due to a buffer > >>>overflow) > >> > >> They should have checked what happens while optimising. Failing > >> that they shouldn't have optimised. > > > >The right way to do that in C is with a volatile cast. > > Is it? I haven't read the C specification on "volatile" in a while, but "volatile" is supposed to prevent optimizing away reads or writes to memory or ports. "volatile" is used to tell the compiler that something outside the context of the compiled C code is modifying memory locations or updating values, e.g., ports, such as from hardware or another program. Of course, casting an integer to a memory or port address is undefined behavior in C, or compiler defined behavior. Rod Pemberton