Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29353 Discussions

[bug report IF 12.0.4.196] Compiler catastrofic error with deferred-length character functions

svrider
Beginner
660 Views
Hi,

I obtain an "Internal compiler error" when I try to write to screen the result of a deferred-length character function, directly appened to another character string.

The compiler is :
Intel Visual Fortran Compiler XE version 12.0 Update 4 for Windows (Package ID: w_fcompxe_2011.4.196)

The code is :
[fortran]!=============================================================================================================
program test_dlc
!=============================================================================================================
implicit none

character(len=:), allocatable :: txt

interface
  Function Test(str1)
  character(len=:),allocatable :: Test
  character(len=*),intent(in)  :: str1
  end Function
end interface

txt ='hello'

write(*,*) txt
write(*,*) Test(txt)                 ! This line is OK
write(*,*) Test(txt)//' world'       ! This line causes the compiler crash in version 12.0.4.196 !!!

end program test_dlc


!=============================================================================================================
Function Test(str1) ! deferred-length character function
!=============================================================================================================
implicit none

character(len=:),allocatable :: Test ! deferred-length character
character(len=*),intent(in)  :: str1

Test=str1

end Function Test
[/fortran]

The command-line is :
ifort test_dlc.f90

The error message is :
Intel Visual Fortran Compiler XE for applications running on IA-32, Version 12.0 Build 20110427
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.

test_dlc.f90
0_1855

D:\\utilit\\Fortran\\sources\\DIVERS\\test_dlc.f90(19): 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.
compilation aborted for D:\\utilit\\Fortran\\sources\\DIVERS\\test_dlc.f90 (code 1)



For information, I don't have this problem with ifort 11.1.070
0 Kudos
5 Replies
lklawrie
Beginner
660 Views
I had a similar problem with gfortran. When I did this to it, it worked okay:

!=============================================================================================================
program test_dlc
!=============================================================================================================
implicit none

character(len=:), allocatable :: txt

txt ='hello'

write(*,*) txt
write(*,*) Test(txt) ! This line is OK
write(*,*) Test(txt)//' world' ! This line causes the compiler crash in version 12.0.4.196 !!!

contains


!=============================================================================================================
Function Test(str1) ! deferred-length character function
!=============================================================================================================
implicit none

character(len=:),allocatable :: Test ! deferred-length character
character(len=*),intent(in) :: str1

Test=str1

end Function Test

end program test_dlc

0 Kudos
Steven_L_Intel1
Employee
660 Views
Thanks - we'll take a look.
0 Kudos
svrider
Beginner
660 Views
@lklawrie
Your solution (with contains) doesn't work with IF 12.0.4.196 :-(
I have also tried to put this function into a separate Module => Internal error !

@all
But the 2 following lines are OK :

[fortran]write(*,*) trim(Test(txt))//' world'[/fortran]


and

[fortran]character(len=:), allocatable :: txt2
...
txt2=Test(txt) ; write(*,*) txt2//' world'[/fortran]
0 Kudos
Steven_L_Intel1
Employee
660 Views
Thanks - I have escalated this as issue DPD200170710. It is the concatenation of the function result that triggers the problem - it does not matter how you declare the function.
0 Kudos
Steven_L_Intel1
Employee
660 Views
This has been fixed for a future release. The workaround is to assign the function value to a local variable and use the variable in the concatenation.
0 Kudos
Reply