- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While doing some tests, I found a ICE generated by ifort with the following code:
module mod1
implicit none
abstract interface
function fintf(n)
integer, intent(in) :: n
integer, allocatable, target :: fintf(:)
end function
end interface
procedure(fintf), pointer :: fptr_ => null()
contains
function f1__(n)
integer, intent(in) :: n
integer, target :: f1__(n)
integer :: i
do i = 1, n
f1__(i) = i
enddo
end function
function f2(n)
integer, intent(in) :: n
integer, allocatable, target :: f2(:)
f2 = f1__(n)
end function
subroutine sub(n)
integer, intent(in) :: n
integer, pointer :: res(:)
! This causes ICE with ifort, stack overflow with ifx (using fptr_!!)
! inhibits: "error #6678: When the target is an expression it must deliver a pointer result."
res => fptr_(n)
print *, res
end subroutine
end module
program main
use mod1
implicit none
fptr_ => f2
call sub(2)
end program
ifx causes (sometimes) a stack overflow error.
Apparently, the use of the function pointer instead of the actual function, inhibits catching at compile time the error.
error #6678: When the target is an expression it must deliver a pointer result
Hope I'm not saying some stupid things.
Cheers
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An ICE is always a compiler bug and therefore, you should find Intel staff quite receptive to your example throwing one with IFORT.
As to your code, note you can view the attributes of a function result such as `ALLOCATABLE` and `TARGET` to only hold during the execution phase of the function, once it returns the attributes are no longer effective. Therefore your code on line 32 does not conform.
What exactly are you after?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks for your always prompt clarifications. They help a lot.
I was just doing some experiments, and fell into this (erroneous) situation, which with ifort Version 2021.7.1 Build 20221019_000000 caused an ICE, and reported it. I didn't try with newer version, maybe that has been fixed.
I thought that both ifort and ifx should have been able to catch the same error using the procedure pointer as when calling the function directly. Am I wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for reporting this! I filed a bug, CMPLRLLVM-48602. I'll let you know about a fix. You have advice from @FortranFan.
What's alarming is that ifx silently accepts the code and prints the wrong answers! That is dangerous for our developers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Barbara_P_Intel , here's a related ICE with IFX this time that the compiler team hopefully won't mind working on:
abstract interface
function Ifunc() result(r)
integer :: r
end function
end interface
procedure(Ifunc), pointer :: f
integer, pointer :: n
n => f()
end
C:\temp>ifx /c /standard-semantics /free p.f
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2023.1.0 Build 20230320
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.
#0 0x00007ff6f88a075a (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x30075a)
#1 0x00007ff6f88a072a (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x30072a)
#2 0x00007ff6f87989a4 (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x1f89a4)
#3 0x00007ff6f879a673 (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x1fa673)
#4 0x00007ff6f881a9d2 (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x27a9d2)
#5 0x00007ff6f8868d47 (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x2c8d47)
#6 0x00007ff6f88e1168 (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x341168)
#7 0x00007ff6f88efc61 (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x34fc61)
#8 0x00007ff6f88f206f (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x35206f)
#9 0x00007ff6f88f265c (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x35265c)
#10 0x00007ff6f88f4b66 (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x354b66)
#11 0x00007ff6f88f206f (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x35206f)
#12 0x00007ff6f88eeffd (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x34effd)
#13 0x00007ff6f88f206f (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x35206f)
#14 0x00007ff6f876f90a (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x1cf90a)
#15 0x00007ff6f876f34a (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x1cf34a)
#16 0x00007ff6f895c31e (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x3bc31e)
#17 0x00007ff6fadc6060 (C:\PROGRA~2\Intel\oneAPI\compiler\latest\windows\bin-llvm\xfortcom.exe+0x2826060)
#18 0x00007ffd50e57614 (C:\WINDOWS\System32\KERNEL32.DLL+0x17614)
#19 0x00007ffd51b426a1 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x526a1)
p.f(8): error #5623: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error.
n => f()
--------^
compilation aborted for p.f (code 3)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also, please note the above shown simple ICE case with IFX is processed with no diagnostics with IFORT whereas the code does not conform. So if you don't mind, can you please bring it to the attention of the compiler team?
abstract interface
function Ifunc() result(r)
integer :: r !<-- can add ALLOCATABLE and/or TARGET attributes, makes no difference, code doesn't conform
end function
end interface
procedure(Ifunc), pointer :: f
integer, pointer :: n
n => f()
end
C:\temp>ifort /c /standard-semantics /free p.f
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.9.0 Build 20230302_000000
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.
C:\temp>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, @FortranFan. I added your reproducer to the case. Fingers-crossed that it's the same bug.
gfortran prints the same error message for both cases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With the release of ifx 2024.2 in mid-2024, the ICE is gone and appropriate error messages are printed.
Check that out in a few months.
![](/skins/images/D3C0B914909A6564BBB97F4AD1ED1973/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