- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a small Fortran code that does not compile with both Intel and gfortran under any circumstances. Specifically, the following code yields an Internal compiler error with Intel ifort compiler version 2021.2, but gfortran compiles and runs it without any issues.
module bug_mod
implicit none
interface
pure module function bug(Array) result(ArrayNew)
character(*), intent(in), contiguous :: Array(:)
character(len(Array)) , allocatable :: ArrayNew(:) ! catastrophic internal error with ifort 2021.2. Fine with gfortran 10.3
!character(:) , allocatable :: ArrayNew(:) ! catastrophic internal error with gfortran 10.3. Fine with ifort 2021.2
end function
end interface
end module bug_mod
submodule (bug_mod) implementation_smod
implicit none
contains
module procedure bug
allocate(ArrayNew, source = Array)
end procedure
end submodule implementation_smod
program main
use bug_mod, only: bug
character(2) :: Array(3) = ["AA", "BB", "CC"]
character(2), allocatable :: ArrayNew(:)
ArrayNew = bug(Array)
end program main
Interestingly, if I uncomment the commented line in the above code and comment out the line above it, then ifort compiles and runs the code happily, while gfortran returns an internal compiler error. Which one is right? Both seem to be compiler bugs.
The issue for both compilers seems to be the separation of interface from the implementation. If I duplicate the interface in the submodule, both compilers can compile and run the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For whatever it's worth, I think the code you have posted conforms to the standard. Regardless, an internal compiler error is always a compiler bug. I suggest you submit support requests with both the compiler implementors.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For whatever it's worth, I think the code you have posted conforms to the standard. Regardless, an internal compiler error is always a compiler bug. I suggest you submit support requests with both the compiler implementors.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page