[cfe-dev] [RFC] add Function Attribute to disable optimization

Jeffrey Walton noloader at gmail.com
Mon Jun 17 17:34:17 PDT 2013


On Mon, Jun 17, 2013 at 8:23 PM, Jeffrey Walton <noloader at gmail.com> wrote:
> On Mon, Jun 17, 2013 at 7:19 PM, Joshua Cranmer 🐧 <Pidgeot18 at gmail.com> wrote:
>> On 6/17/2013 5:32 PM, Jeffrey Walton wrote:
>>> On Mon, Jun 17, 2013 at 6:23 PM, Sean Silva <silvas at purdue.edu> wrote:
>>>>
>>>> ...
>>>
>>> That brings up a good point. As I understand it, volatile is
>>> essentially implementation defined. What is Clang/LLVM's
>>> interpretation?
>>
>> Volatile has an explicit definition in C99/C11/C++03/C++11, and it's roughly
>> the same in all of them. Volatile objects "may be modified in ways unknown
>> to the
>> implementation or have other unknown side effects" (to quote C99), and the
>> implementation must therefore preserve the accesses and their order even
>> when optimizing.
> OK, thanks. I must have been quoted something else on another list.
> I'll try and locate the email.
Here's what I found. It was from Andrew Haley, who I beleve is one of
the GCC devs.

GCC List >>> A good discussion on the subject can be found at
GCC List >>> http://gcc.gnu.org/ml/gcc-help/2012-03/msg00239.html.
GCC List >>>
GCC List >> The thread includes a discussion of Microsoft's and GCC's
GCC List >> interpretation of the keyword. The interpretations were so
different I
GCC List >> wondered if it was 'implementation defined' in the standard.
GCC List >
GCC List > Yes: 6.7.3 Type qualifiers, "What constitutes an access to an object
GCC List > that has volatile-qualified type is implementation-defined."

I'm pretty sure that's where I latched onto 'volatile' being
implementation defined. I tend to trust the opinions of Ian Lance
Taylor, Jonathan Wakely, and Andrew Haley when it comes to GCC. Andrew
cited the standard above.

Jeff




More information about the cfe-dev mailing list