[fpc-devel] volatile variables

Sven Barth pascaldragon at googlemail.com
Thu Jun 30 15:42:42 CEST 2011


Am 30.06.2011 14:53, schrieb Michael Schnell:
> On 06/30/2011 11:45 AM, Jonas Maebe wrote:
>>
>> There is none. FPC has a "volatile" modifier in svn trunk, but it
>> currently only affects the node tree optimizer.
>> ...
>> Its only use is for memory mapped I/O.
> I don't suppose the node tree optimizer is memory mapped I/O ???

No, but the node tree optimizer might optimize away two consecutive 
reads from or writes to a "memory mapped" variable which might be 
necessary for the hardware...

e.g. (theoretical pseudo code scenario)

=== source begin ===

var
   a: Integer; volatile; absolute $42;
   b: Integer;
begin
   b := a; // this might be necessary for the hardware, but the 
optimizer will remove the first statement if it doesn't know about 
"volatile"
   b := a;
end;

=== source end ===

Regards,
Sven



More information about the fpc-devel mailing list