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

Array bounds and shape checking fails to detect runtime errors, ifort 2021.4.0 Build 20210910_000000

Mike_D_5
Beginner
447 Views

Is there a fix for this?

 

Array bounds and shape checking fails to detect runtime errors in all but the simplest assignment cases. Any operations on the RHS seem to disable checking even though the operations are returning mis-matched arrays. All these demonstrator cases are detected correctly by gfortran with the -bounds-check option. Failure to detect these errors slows down development and discourages use of the intel compiler.

 

Demonstration:

 

ifort -o trya2d_c -check shape trya2d_c.f90

./trya2d_c

 

  SHAPE(htau) 100 100

  L/UBOUND(htau) 2 2 101 101

  SHAPE(gphit) 102 102

  L/UBOUND(gphit) 1 1 102 102

This line is not detected as a shape mismatch even with -check shape at compilation:

htau(:,:) = MAX( 0.5, MIN( 30., 45.* ABS( SIN( 3.142/180. * gphit(:,:) ) ) ))

Even though the shapes do not match:

  100 100 102 102

  Note: this error is detected correctly by gfortran with -bounds-check

 

In fact, a simple operation with the RHS prevents shape checking:

 A: htau(:,:) = 1.0 * gphit(:,:) 102 102

 B: htau(:,) = gphit(:,:) * 1.0 102 102

 

Only a simple assignment is trapped correctly:

 C: htau(:,:) = gphit(:,:) 102 102

forrtl: severe (408): fort: (33): Shape mismatch: The extent of dimension 2 of array HTAU is 100 and the corresponding extent of array GPHIT is 102

 

Image PC Routine Line Source

trya2d_c 0000000000406F8F Unknown Unknown Unknown

trya2d_c 0000000000404370 Unknown Unknown Unknown

trya2d_c 0000000000403852 Unknown Unknown Unknown

libc-2.17.so 00002ADBAFD7E555 __libc_start_main Unknown Unknown

trya2d_c 0000000000403769 Unknown Unknown Unknown

Demonstrator program:

 

cat trya2d_c.f90

REAL, ALLOCATABLE, DIMENSION(:,:) :: htau, gphit

ALLOCATE(htau(2:101,2:101), gphit(102,102))

WRITE(*,*) ' SHAPE(htau)     ', SHAPE(htau)

WRITE(*,*) ' L/UBOUND(htau)  ', LBOUND(htau), UBOUND(htau)

WRITE(*,*) ' SHAPE(gphit)    ', SHAPE(gphit)

WRITE(*,*) ' L/UBOUND(gphit) ', LBOUND(gphit), UBOUND(gphit)

!

write(*,'(a)') 'This line is not detected as a shape mismatch even with -check shape at compilation: '

write(*,'(a)') 'htau(:,:) =  MAX(  0.5, MIN( 30., 45.* ABS( SIN( 3.142/180. * gphit(:,:) ) ) ))'

htau(:,:) =  MAX(  0.5, MIN( 30., 45.* ABS( SIN( 3.142/180. * gphit(:,:) ) ) ))

write(*,'(a)') 'Even though the shapes do not match: '

write(*,*) SHAPE(htau), SHAPE( MAX(  0.5, MIN( 30., 45.* ABS( SIN( 3.142/180. * gphit(:,:) ) ) )))

write(*,'(a)') '  Note: this error is detected correctly by gfortran with -bounds-check '

!

write(*,'(a)') 'In fact, a simple operation with the RHS prevents shape checking: '

write(*,*) 'A: htau(:,:) = 1.0 * gphit(:,:) ', SHAPE(1.0 * gphit(:,:))

htau(:,:) =   1.0 * gphit(:,:)

!

write(*,*) 'B: htau(:,) = gphit(:,:)  * 1.0 ',SHAPE(gphit(:,:)  * 1.0)

htau(:,:) =   gphit(:,:)  * 1.0

!

write(*,'(a)') 'Only a simple assignment is trapped correctly: '

write(*,*) 'C: htau(:,:) = gphit(:,:) ',SHAPE(gphit(:,:))

htau(:,:) =   gphit(:,:)

!

write(*,*) 'D'

end

 

 

Labels (1)
0 Kudos
3 Replies
Barbara_P_Intel
Moderator
347 Views

This runtime error is not yet fixed in the internal releases. I filed a bug report, CMPLRLLVM-40141. I will post when a fix is implemented.



Mike_D_5
Beginner
201 Views

Hello, has there been any further work done on this bug.. CMPLRLLVM-40141?

 

Thanks.

Barbara_P_Intel
Moderator
190 Views

I checked the status. No fix yet.


Reply