[RFC] Volatile attribute for host/use-associated variables (PR30522)

Tobias Burnus burnus@net-b.de
Sat Feb 3 20:57:00 GMT 2007


Hi,

Thomas Koenig wrote:
> Stupid question:  How would the user program know?
>   
Well, it can't know it.

> VOLATILE, as I understand it, means we can't do certain
> optimizations.  If we don't do these optimizations anywhere,
> can we generate wrong code somehow?
>   
No we don't generate wrong code, but we would like to generate faster
code. This part of PR30522 is not a wrong-code, but a missing-optimization.

At least with my "volatile_ns" patch, the attached program compiles
correctly with gfortran. However, we don't optimize the if conditions
away for the cases where we could.

I don't have any feeling how likely it is to have a variable which is
not volatile anywhere except in one subroutine, but one can surely dream
up cases where this happens. (VOLATILE is too new and too badly
supported by Fortran compilers to check against real-world code.)

(I just checked what other compilers do and ifort9, ifort10beta, g95 and
nagf95 reject the valid program. sunf95 accepts it but according to
"string a.out" it does not optimize.)

Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: volatile.f90
Type: text/x-fortran
Size: 2864 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070203/c012bc14/attachment.bin>


More information about the Fortran mailing list