[fpc-devel] volatile variables

Michael Schnell mschnell at lumino.de
Tue Jun 28 16:33:43 CEST 2011


On 06/28/2011 04:23 PM, Jonas Maebe wrote:
>
> On 28 Jun 2011, at 15:54, Michael Schnell wrote:
>
>>
>> I believe that inserting some ptherad_mutex... calls will not force 
>> the compiler to bother about some intermediate values of a non 
>> volatile variable.
>
> You believe wrongly.
>
As the compiler does not know anything about what pthread_mutex does 
just the existence of a function call at that location can trigger that 
it behaves different from the case that no function call is done.

And this has been discussed in the other message: If the variable in 
fact is global the compiler needs to avoid caching it, if it is static 
and the function is in another module it might still decide to cache it, 
but you are right: it is not likely that it does make this difference.

-Michael



More information about the fpc-devel mailing list