Compiler bug?

Compiler bug?

Hi

I attempted to compile my code but the compiler crashed. I have managed to isolate the problem in the following skeleton code.

PROGRAM DEMO

IMPLICIT NONE

INTEGER :: LengthString
INTEGER :: I

CHARACTER(LEN=:), ALLOCATABLE :: String(:)

LengthString=10

ALLOCATE(CHARACTER(LengthString) :: String(10))

DO I=1,10
  IF(I*2/2 == I) THEN
    String(I) = 'abcdefghij'
  ELSE
    String(I) = 'nopqrstuvw'
  ENDIF
ENDDO

DO I=1,10
  IF(String(I)(1:1) == 'a') THEN
    WRITE(*,*) 'match found'
  ELSE
    WRITE(*,*) 'no match found'
  ENDIF
ENDDO

STOP
END PROGRAM DEMO

but this results with

Compiling with Intel(R) Visual Fortran Compiler XE 12.0.4.196 [IA-32]...
demo.f90
\intel_compiler_failure\intel_compiler_failure\demo.f90(23): 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 C:\Users\User\Documents\oslo_vision_tortoise\intel_compiler_failure\intel_compiler_failure\intel_compiler_failure\demo.f90 (code 1)

The Fortran is standard and this is easily shown by making one of two simple changes.

The first is to define the length of the string at compile time, thus

PROGRAM DEMO

IMPLICIT NONE
INTEGER :: I

CHARACTER(LEN=10), ALLOCATABLE :: String(:)

ALLOCATE(String(10))

DO I=1,10
  IF(I*2/2 == I) THEN
    String(I) = 'abcdefghij'
  ELSE
    String(I) = 'nopqrstuvw'
  ENDIF
ENDDO

DO I=1,10
  IF(String(I)(1:1) == 'a') THEN
    WRITE(*,*) 'match found'
  ELSE
    WRITE(*,*) 'no match found'
  ENDIF
ENDDO

STOP
END PROGRAM DEMO

 

compiles fine. However, I need to length of the string to be dynamic so a workaround is to copy the array element under test to a scalar string variable, thus

PROGRAM FUDGE

IMPLICIT NONE

INTEGER :: LengthString
INTEGER :: I

CHARACTER(LEN=:), ALLOCATABLE :: String(:)
CHARACTER(LEN=:), ALLOCATABLE :: TempString

LengthString=10

ALLOCATE(CHARACTER(LengthString) :: String(10))
ALLOCATE(CHARACTER(LengthString) :: TempString)

DO I=1,10
  IF(I*2/2 == I) THEN
    String(I) = 'abcdefghij'
  ELSE
    String(I) = 'nopqrstuvw'
  ENDIF
ENDDO

DO I=1,10
  TempString = String(I)
  IF(TempString(1:1) == 'a') THEN
    WRITE(*,*) 'match found'
  ELSE
    WRITE(*,*) 'no match found'
  ENDIF
ENDDO

STOP
END PROGRAM FUDGE

also compiles without a problem.

 

Cheers

Clive

publicaciones de 3 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

I can reproduce this error in all 12.0 and 12.1 compiler versions, but it is fixed in version 13.0 (Composer XE 2013). The current version is Composer XE 2013 Update 1.

Steve - Intel Developer Support

OK Steve. I don't know when I will upgrade to the latest  version but since I have my workaround it is not a big deal.

Thanks

Clive

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya