- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This question has been addressed before. See https://software.intel.com/en-us/forums/topic/270242 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, I will take a look at the huge() function, since that is what I was trying to achieve.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page