Question on volatile functions and GCC
Wed Mar 6 10:22:00 GMT 2013
On 03/05/2013 06:39 PM, Jeffrey Walton wrote:
> On Tue, Mar 5, 2013 at 4:27 AM, David Paterson <firstname.lastname@example.org> wrote:
>> On 4 March 2013 23:40, Jeffrey Walton <email@example.com> wrote:
>>> I believe GCC's interpretation of the use for 'volatile' is memory
>>> mapped hardware.
>> In addition to Jonathan's answer on the use of "volatile", it's worth adding
>> that it's not only used for memory mapped hardware. There are many other
>> uses, such as inter-thread communication, or indeed the example you
>> show below.
> A good discussion on the subject can be found at
> The thread includes a discussion of Microsoft's and GCC's
> interpretation of the keyword. The interpretations were so different I
> wondered if it was 'implementation defined' in the standard.
Yes: 6.7.3 Type qualifiers, "What constitutes an access to an object
that has volatile-qualified type is implementation-defined."
> In the end, I think the C/C++ committee needs to supply another
> keyword to ensure program statements are never removed and executed
> in-situ with no side effects (perhaps 'pin'). They gave the compiler
> writer's 'restrict' so they could optimize. The security minded folks
> should get something too to ensure program correctness even when the
> optimizer is aggressive.
But that'd still be impossible to define in terms of the abstract
machine, so it wouldn't help.
We now have the C++11 memory model. Are you really saying that you
can't figure out how to use atomic_store() to write a secure memory
More information about the Gcc-help