Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Sat, 07 Jul 2012 04:00:44 -0500 From: Gareth Owen Newsgroups: comp.lang.c Subject: Re: Clarification on the applicability of compile-time optimization to a struct variable which encompasses a mixture of fields declared as volatile and non-volatile individually References: <94eafd27-6aba-4a17-9403-d42912312e6c@googlegroups.com> <0.8f83cddfeac55b9f2de1.20120705232249BST.87k3yhalvq.fsf@bsb.me.uk> <7ee0b658ce2dc96-3111f@gmail.com> Date: Sat, 07 Jul 2012 10:00:51 +0100 Message-ID: <87a9zcuerg.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:5CX0frn+yEUDicRwPuIT2WpyAs8= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 15 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-Yldv/z/dQzilzQgilozt+US3qpmtTveExFfmj1PNe4ci8TsLYhDt46KGA+2VZtEuSc5Xm9UYCH82Mvp!JPKDEiNmuHGG25DogDwuoKBqv6mBZppYZFJhZy1Kq+mNj3CI5VAzUJw8zDXBhl+C9J5xLA== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2010 Xref: csiph.com comp.lang.c:23143 Tim Rentsch writes: > Question: what values for a and b might thread Y print? > > Answer: Besides the obvious possibilities of {1,2}, {3,2}, > and {3,4}, the Standard allows a conforming implementation > to define volatile access in such a way that thread Y might > print 1 for a but 4 for b. Would it be correct to say that if both a & b are volatile, then the compiler may not reorder them, but the processor may (in the absence of an explicit memory barrier)? In which case, volatile may be (non-portably) sufficient for i386 uni-processors, say.