- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assuming, that one has the following code:
main.f90:
program main
implicit none
common /mem/ imem
integer :: imem
imem = 0
call test(imem)
end program main
subroutine update_imem
implicit none
common /mem/ imem
integer :: imem
imem = 30
end subroutine update_imem
test.f90:
subroutine test(imem)
integer :: imem
print *, imem
call update_imem()
print *, imem
end subroutine test
Compilation:
ifx test.f90 main.f90 -O0 -o a.exe
Running gives the output:
0
30
that is expected.
However, if it will be compiled with -O3:
ifx test.f90 main.f90 -O0 -o a.exe
the output will be
0
0
The expected output should be the same as without optimisations. This behaviour is for NAG/ArmFlang/gfortran/LLVMFlang/AOCC/ifort compilers, but not for ifx.
@Ron_Green , could you please have a look?
Related issues:
https://community.intel.com/t5/Intel-Fortran-Compiler/pointer-to-procedure-is-constant-while-should-not/m-p/1634195
https://community.intel.com/t5/Intel-Fortran-Compiler/common-variable-passed-as-argument-of-function-is-overoptimized/m-p/1573128
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is an invalid program. It violates:
In other words, you're aliasing the dummy argument and the COMMON variable, and that is not allowed here.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is an invalid program. It violates:
In other words, you're aliasing the dummy argument and the COMMON variable, and that is not allowed here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Steve_Lionel, thank you so much. It was a bit hard for me to understand those sentences with "unless".
So, it is time to update 40k LoC with this violation...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can, for now, compile with /assume:dummy_aliases and I think it should do what you want. It is still invalid code.
All of the "unless" bullets are cases where you are allowed to make aliases - the TARGET attribute (implied by POINTER, which I think is relevant to your other thread), is one of these.
One of the core tenets of Fortran is that aliasing is generally disallowed, unless you tell the compiler explicitly that it can occur.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Steve_Lionel, thank you! With `-assume dummy_aliases`, all tests were passed. And thank you for explanation about Fortran.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page