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

Ifx 2025.0.0 bug in bounds checking?

MattiTaskinen
Beginner
413 Views

There seems to be a bug in bounds checking of ifx version 2025.0.0.

Example code:

! OPTS="-traceback -O0 -g -check bounds"
! ifx $OPTS bug.f90 -o bug
! IFORT=/opt/intel/oneapi/compiler/2023.2.1/linux/bin/intel64/ifort
! $IFORT $OPTS bug.f90 -o bug-ifort

program bug
  implicit none
  integer :: table(2,1)
  integer :: j = 1,     a = 42, b = 17
  integer, parameter :: c = 42, d = 17

  table(:,:) = 0
  
  print *,'j = ', j
  print *,'a = ', a
  print *,'b = ', b
  print *,'c = ', c
  print *,'d = ', d
  print *,'size(table,1) = ', size(table,1)
  print *,'size(table,2) = ', size(table,2)
  ! ...........................................................................
  print *,'Test 1 (no j)'
  table(1,1) = a                     ! WORKS
  table(2,1) = b

  print *,'Test 2 (no j)'
  table(1:2,1) = (/ 42, 17 /)        ! WORKS

  print *,'Test 3 (no j)'
  table(1:2,1) = (/ c, d /)          ! WORKS

  print *,'Test 4 (no j)'
  table(1:2,1) = (/ a, b /)          ! WORKS
  ! ...........................................................................
  print *,'Test 1 (with j)'
  table(1,j) = a                     ! WORKS
  table(2,j) = b

  print *,'Test 2 (with j)'
  table(1:2,j) = (/ 42, 17 /)        ! WORKS

  print *,'Test 3 (with j)'
  table(1:2,j) = (/ c, d /)          ! WORKS

  print *,'Test 4 (with j)'
  table(1:2,j) = (/ a, b /)          ! DOES NOT WORK with ifx, ifort OK.
  ! ...........................................................................  
  print *, 'table(1,:) = ', table(1,:)
  print *, 'table(2,:) = ', table(2,:)
  
end program bug

When compiled with bounds checking:

ifx -traceback -O0 -g -check bounds bug.f90 -o bug

produces false bounds checking error on the last test "Test 4 (with j)":

 j =            1
 a =           42
 b =           17
 c =           42
 d =           17
 size(table,1) =            2
 size(table,2) =            1
 Test 1 (no j)
 Test 2 (no j)
 Test 3 (no j)
 Test 4 (no j)
 Test 1 (with j)
 Test 2 (with j)
 Test 3 (with j)
 Test 4 (with j)
forrtl: severe (408): fort: (3): Subscript #1 of the array TABLE has value 0 which is less than the lower bound of 1

Image              PC                Routine            Line        Source             
bug                00000000004062C4  bug                        46  bug.f90
bug                000000000040516D  Unknown               Unknown  Unknown
libc.so.6          00000E361E629D90  Unknown               Unknown  Unknown
libc.so.6          00000E361E629E40  __libc_start_main     Unknown  Unknown
bug                0000000000405085  Unknown               Unknown  Unknown

With larger table size (2,11) in the actual larger program where this bug was found the error message claimed Subscript #1 to be 78848848 even though the first indexes were the same 1:2.

This with ifx version 2025.0.0 20241008 on Ubuntu 22.04. Ifort (2021.10.0 2023060) and gfortran work OK.

Can anyone else reproduce the error?

0 Kudos
1 Solution
andrew_4619
Honored Contributor III
408 Views
0 Kudos
2 Replies
andrew_4619
Honored Contributor III
409 Views

That look a bit like a 2024.x.x bug that I reported some weeks back. https://community.intel.com/t5/Intel-Fortran-Compiler/Exception-in-IFX-2024-2-0-Intel-R-64/m-p/1610145#M172758

 

0 Kudos
MattiTaskinen
Beginner
401 Views

Yes. It is probably the same bug.

Thanks.

0 Kudos
Reply