Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Default values in #define Date: Wed, 31 Aug 2016 12:30:16 -0700 Organization: None to speak of Lines: 21 Message-ID: References: <1d377167-a33a-402e-89ee-d3efa06d95ab@googlegroups.com> <87twebuwwn.fsf@gmail.com> <36a5bcc3-9e30-468c-a3e1-4b9c9788d395@googlegroups.com> <1Kgvz.279$6d.174@fx26.iad> <8277ffd2-121d-4f3a-9bb0-ad3068696415@googlegroups.com> <502669cd-f0fc-4b99-8c8a-0d806c8b5f20@googlegroups.com> <566c947b-91d6-43c1-86aa-772f6cf21e35@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="4935"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sCsn5GQwt97VNeDTEqs9v" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:kXolIlS3WWSn6Kzm82dAiXTvvU0= sha1:Hxbq2RY6dxo7ZdoA1B/mafnD0HQ= Xref: csiph.com comp.lang.c:93007 supercat@casperkitty.com writes: > On Wednesday, August 31, 2016 at 11:22:01 AM UTC-5, Keith Thompson wrote: >> I was (somewhat vaguely) thinking that an implementation is still >> allowed to optimize away some apparent accesses to volatile objects. >> Which, now that I think about it, doesn't make a whole lot of sense. > > If a compiler knows that code will be running on hardware where volatile > reads of a certain location will always yield the value 12, it would be > entitled to replace reads of that location with loads of a constant 12 > *provided* that the read still acted as a barrier to certain kinds of > optimization. Not if the read has effects other than yielding 12. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"