- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This program below with a cascaded optional array, which is assumed-rank in the last called routine, works fine with gfortran, but fails on execution with any version of ifort/ifx.
module foo
implicit none
contains
subroutine foo1(a)
real, intent(in), optional :: a(:)
call foo2(a)
end subroutine
subroutine foo2(a)
real, intent(in), optional :: a(..)
if (present(a)) then
print*, rank(a)
else
print*, "a not present"
end if
end subroutine
end module
program bar
use foo
implicit none
call foo1()
end
Is it a ifort/ifx bug, or is the code invalid?
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
libc.so.6 00007F889BE42520 Unknown Unknown Unknown
output.s 0000000000405214 Unknown Unknown Unknown
output.s 0000000000405450 Unknown Unknown Unknown
output.s 000000000040518D Unknown Unknown Unknown
libc.so.6 00007F889BE29D90 Unknown Unknown Unknown
libc.so.6 00007F889BE29E40 __libc_start_main Unknown Unknown
output.s 00000000004050A5 Unknown Unknown Unknown
Try it here: https://godbolt.org/z/8svecrEGc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you state, this segfaults with the current ifx 2024.0.0. But I tested with our internal code that will come with our next update release, 2024.1.0. In this future version of 2024.1.0 it is fixed in ifx and ifort
$ ifx repro.f90
$ ./a.out
a not present
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you state, this segfaults with the current ifx 2024.0.0. But I tested with our internal code that will come with our next update release, 2024.1.0. In this future version of 2024.1.0 it is fixed in ifx and ifort
$ ifx repro.f90
$ ./a.out
a not present
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a similar issue even with the 2024.1 release:
integer, allocatable :: x
print*,'When x is unallocated:'
call foo(x); call foo_ar(x)
print*,'When x is allocated:'
x = 1
call foo(x); call foo_ar(x)
contains
subroutine foo ( x )
integer, optional, intent(in) :: x
if ( present(x) ) then
print*,'- with foo: x is present'
else
print*,'- with foo: x is absent'
end if
end subroutine foo
subroutine foo_ar ( x )
integer, optional, intent(in) :: x(..)
if ( present(x) ) then
print*,'- with foo_ar: x is present'
else
print*,'- with foo_ar: x is absent'
end if
end subroutine foo_ar
end
I get with ifx ((IFX) 2024.1.2 20240508):
When x is unallocated:
- with foo: x is absent
- with foo_ar: x is present
When x is allocated:
- with foo: x is present
- with foo_ar: x is present
While with gfortran (GNU Fortran (SUSE Linux) 7.5.0):
When x is unallocated:
- with foo: x is absent
- with foo_ar: x is absent
When x is allocated:
- with foo: x is present
- with foo_ar: x is present
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A new and different bug. I will open a new bug report. Thank you for finding this.
15.5.2.13 Argument presence and restrictions on arguments not present
A dummy argument or an entity that is host associated with a dummy argument is not present if the dummy argument
- does not correspond to an actual argument
- corresponds to an actual argument that is not present, or
- does not have the ALLOCATABLE or POINTER attribute, and corresponds to an actual argument that
- has the ALLOCATABLE attribute and is not allocated, or
- has the POINTER attribute and is disassociated;
otherwise, it is present.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
bug tracking ID is CMPLRLLVM-59233
![](/skins/images/8B6E2C8F64F54CBD7F7262AA46F575DA/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page