Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

another internal compiler error

mrentropy1
Beginner
1,373 Views
(I'm also peter_williamsagilent.com - at home and can't remember psswd & can't access work email. :) ) ANYway.... Here's another bit of code that breaks the compiler. Platform is x86_64 linux.

$ ifort -c breaker.f90
breaker.f90(18): warning #6178: The return value of this FUNCTION has not been defined.
function dummy (i) result (x)
-----------------------------^
breaker.f90(37): catastrophic error: **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.
thing2 = baz(myfoo%bar,i)
-----------^
compilation aborted for breaker.f90 (code 3)

By the way I can make warning 6178 go away by rewriting function "dummy" below without the "result" clause, but I don't understand why the result clause is causing problems either, so I've included it as is. Again, I'm not sure this is functional Fortran. I seem to uncover these problems playing around with extensible types trying to learn 2003 features, doing the "see if this compiles" method of dinking around.....

Oh yea almost forgot:
peter@cygnus:~$ uname -a
Linux cygnus 2.6.28-14-generic #47-Ubuntu SMP Sat Jul 25 01:19:55 UTC 2009 x86_64 GNU/Linux
peter@cygnus:~$ ifort --version
ifort (IFORT) 11.1 20090630
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

peter@cygnus:~$


-Peter

[plain]module foo_mod

implicit none
type, public :: foo_type
real :: x
contains
procedure, pass :: bar
end type foo_type

contains

real function bar(foo,i)
class(foo_type), intent(in) :: foo
integer, intent(in) :: i
bar = 0.0
end function bar
!
function dummy (i) result (x)
integer :: i
real :: x
x = 1.0 * i
end function dummy
!
real function baz(pap, i)
procedure (dummy), pointer :: pap => null()
integer, intent(in) :: i
baz = pap(i)
end function baz

end module foo_mod

program main
use foo_mod
real :: thing2
type(foo_type) :: myfoo
integer :: i
thing2 = baz(myfoo%bar,i)
end program main[/plain]
0 Kudos
4 Replies
Kevin_D_Intel
Employee
1,373 Views

Thank you Peter for the convenient reproducer. Unclear where things go awry within the compiler on this one. I forwarded to Development and will update the post as I learn more.

(Internal tracking id: DPD200138694)

(Resolution Update on 11/10/2009): This defect is fixed in the Intel Fortran Compiler Professional Edition 11.1 Update 3, (11.1.059 - Linux).
0 Kudos
mrentropy1
Beginner
1,373 Views

Thank you Peter for the convenient reproducer. Unclear where things go awry within the compiler on this one. I forwarded to Development and will update the post as I learn more.

(Internal tracking id: DPD200138694)

Kevin,

Thank you.

I've also got an even simpler bit of code that -while it doesn't cause an internal compiler seg violation - may be related.

Start with this bit of code:
[plain]module mod

contains

function x1 (i)
x1 = 1.0 * i
end function x1

function x2 (i)
x2 = 2.0 * i
end function x2

end module mod

program main
use mod
procedure (x1), pointer :: xeither => null()
j = 3.0
xeither => x1
y = xeither(j)
write (6,*) y
!
xeither => x2
y = xeither(j)
write (6,*) y
!
end program main
[/plain]
Compile this with ifort with no flags, and it runs fine as expected:
[plain]$ ./a.out
3.000000
6.000000
$
[/plain]
Now, let's try to put a new function in the module that takes a procedure pointer as an argument, and we'll pass it a pointer to procedure x1 (say) in the main program:

[plain]module mod

contains

function x1 (i)
x1 = 1.0 * i
end function x1

function x2 (i)
x2 = 2.0 * i
end function x2

function xwhich (pp,i)
procedure (x1), pointer :: pp
xwhich = pp(i)
end function xwhich

end module mod

program main
use mod
procedure (x1), pointer :: xeither => null()
!
j = 3.0
!
xeither => x1
y = xwhich(xeither,j)
write (6,*) y
!
xeither=> x2
y = xwhich(xeither,j)
write (6,*) y
!
end program main
[/plain]
It's my understanding this is valid Fortran 2003 use of procedure pointers, but I'm not an expert, so I could be wrong. What I'm expecting is a program that gives me identical output to the original program. However, it doesn't compile, and ifort complains about an internal compiler error:

[plain]$ ifort simple.F90
simple.F90(8): internal error: Please visit 'http://www.intel.com/software/products/support' for assistance.
x1 = 1.0 * i
^
[ Aborting due to internal error. ]
compilation aborted for simple.F90 (code 1)
$ [/plain]
The line number given is a hint. In fact, if we had used a "result" clause in the definition of function x1, we now (in this code, but not the original code) would have gotten a nonsensical complaint that the return value of the function isn't defined. Edit the code to add "result" clause:

[plain]module mod

contains

function x1 (i) result (x)
x = 1.0 * i
end function x1

function x2 (i)
x2 = 2.0 * i
end function x2

function xwhich (pp,i)
procedure (x1), pointer :: pp
xwhich = pp(i)
end function xwhich

end module mod

program main
use mod
procedure (x1), pointer :: xeither => null()
!
j = 3.0
xeither => x1
y = xwhich(xeither,j)
write (6,*) y
!
end program main
[/plain]
and get the nonsensical complaint about return value not being defined:

[plain]$ ifort simple.F90
simple.F90(7): warning #6178: The return value of this FUNCTION has not been defined.
function x1 (i) result (x)
--------------------------^
simple.F90(9): internal error: Please visit 'http://www.intel.com/software/products/support' for assistance.
x = 1.0 * i
^
[ Aborting due to internal error. ]
compilation aborted for simple.F90 (code 1)
$[/plain]
Hope that helps.

Peter

0 Kudos
mrentropy1
Beginner
1,373 Views
But check this out - if I NOW put the module function that's supposed to take a procedure pointer, and put it in a SEPARATE module (call it mod2), everything works FINE, plus that old bizarre complaint about the function with a "result" clause not having a defined return value, well, that goes away. Here is the functional code (named simple_works.F90):

[plain]module mod
contains
function x1 (i) result (x)
x = 1.0 * i
end function x1
!
function x2 (i)
x2 = 2.0 * i
end function x2
end module mod

module mod2
use mod
contains
function xwhich (pp,i)
procedure (x1) :: pp
xwhich = pp(i)
end function xwhich
end module mod2

program main
use mod2
procedure (x1), pointer :: xeither => null()
!
j = 3.0
xeither => x1
y = xwhich(xeither,j)
write (6,*) y
!
xeither => x2
y = xwhich(xeither,j)
write (6,*) y
!
end program main[/plain]
and the compilation and run:

[plain]$ ifort simple_works.F90
$ ./a.out
3.000000
6.000000
$
[/plain]
... which is exactly as expected.

So this does appear to be a compiler bug - I *think* the Fortran 2003 standard shouldn't require that xwhich() is defined in a separate module, but maybe I'm wrong, but in any case it breaks the compiler - but, on the other hand, at least in this simple case there's a work-around, plus now there's an even stronger hint about what's going wrong.

Peter

P.S. : I realize now that I should have put
procedure (
0 Kudos
Kevin_D_Intel
Employee
1,373 Views

This defect (DPD200138694) is fixed in the Intel Fortran Compiler Professional Edition 11.1 Update 3, (11.1.059 - Linux).
0 Kudos
Reply