This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Are arrays guaranteed to be affected by a "memory" clobber?
- From: Martin Sebor <msebor at redhat dot com>
- To: Segher Boessenkool <segher at kernel dot crashing dot org>
- Cc: Sebastian <sebastianspublicaddress at googlemail dot com>, gcc-help at gcc dot gnu dot org
- Date: Mon, 15 Jun 2015 12:10:11 -0600
- Subject: Re: Are arrays guaranteed to be affected by a "memory" clobber?
- Authentication-results: sourceware.org; auth=none
- References: <20150610224600 dot 00007d52 at unknown> <557B43CE dot 8020204 at redhat dot com> <20150613200106 dot 00007acc at googlemail dot com> <557F0534 dot 9050201 at redhat dot com> <20150615171954 dot GA12101 at gate dot crashing dot org>
On 06/15/2015 11:19 AM, Segher Boessenkool wrote:
On Mon, Jun 15, 2015 at 11:02:44AM -0600, Martin Sebor wrote:
Let me clarify one important property of the GCC implementation.
In contrast to a strict reading of the C standard, GCC doesn't
require an object to be declared volatile in order to guarantee
that volatile semantics are applied to accesses to it. What
matters is the volatility of the lvalue used to perform the
access.
This isn't documented behaviour though; see PR33053.
Thanks for the pointer!
This subject came up in WG14 recently. While the official C text
doesn't require this behavior, the original intent reflected in
the C99 Rationale, is that it work. (Without it the example that
motivated the introduction of volatile into C wouldn't work.)
Since this is widely relied on, documented in popular articles
on C programming, and required by C++, I plan to submit a proposal
for the October meeting to bring the C standard into alignment with
the C99 Rationale and with C++ which has always required it.
Until the proposal is accepted (assuming it is accepted) it seems
that documenting this guarantee in the GCC manual would give users
a peace of mind and sanction the kernel uses.
Martin