Re: Does dereferencing a volatile pointer produce a volatile element?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 15, 2016 at 11:51 AM, Nicholas Mc Guire <der.herr@xxxxxxx> wrote:
> On Mon, Feb 15, 2016 at 11:37:13AM -0500, Jeffrey Walton wrote:
>> Hi Everyone,
>>
>> As an example:
>>
>>     int a[10];
>>     volatile int* b = a;
>>
>>     for(unsigned i=0; i<10; i++)
>>         *b++ = 0;
>>
>> When the dereference occurs through b, does it produce a volatile element?
>>
> as far as I understand volatile this is just telling
> the compiler that the assignment here can not be reordered
> thats it -

Yes, thanks. I was less concerned about the assignment to the pointer.

> ... it does not change the propertieis of a[] in any
> way if that is what you means with "produce volatile elements"
> with other words if you later use say a[4] = c (with c not
> being volatile) then the compiler can again reorder / optimize
> out things as seen fit.

That's what I was interested in.

Jeff



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux