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

Possible bug in ifort version 14.0.1

Momchil_I_
Beginner
337 Views

Hi,

I have encountered some strange behaviour in the ifort version 14.0.1 by deliberately forcing an overflow of a 32 bit integer on my computer. Here is how to reproduce it

% ifort -v
ifort version 14.0.1

% cat main.f90
program main
  implicit none
  integer i

  i=2**31-10
  do while(.true.)
     i=i+1
     if (i.le.0) then
        exit
     end if
  end do
  print *,'i',i
end program main

% ifort -O0 -std03 -o main main.f90
% ./main
 i -2147483648

% ifort -O1 -std03 -o main main.f90
% ./main
 i -2147483647

% ifort -O2 -std03 -o main main.f90
% ./main
 i -2147483647

I would expect  "i -2147483648" which I obtain with -O0 to be the correct behaviour. Am I missing something here?

Regards,

Momchil

0 Kudos
3 Replies
Momchil_I_
Beginner
337 Views

The following code shows the same behaviour

program main
  implicit none
  integer i

  i=2147483647-10
  do while(i.gt.0)
     i=i+1
  end do
  print *,'i',i
end program main

0 Kudos
mecej4
Honored Contributor III
337 Views

This question has been addressed before. See https://software.intel.com/en-us/forums/topic/270242 .

0 Kudos
Momchil_I_
Beginner
337 Views

Thank you, I will take a look at the huge() function, since that is what I was trying to achieve.

0 Kudos
Reply