This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Are arrays guaranteed to be affected by a "memory" clobber?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]