- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Both current compilers (classical 2021.10.0 20230609, ifx 2023.2.0 20230721) print an overflow warning for the line, defining parameter b2. Interestingly all numbers are correct and output is as it should be. So no internal overflow actually happened.
program smallest_int
implicit none
integer(4), parameter :: a1 = -huge(0_4) - 1_4
integer(4), parameter :: a2 = ibset(0_4, bit_size(0_4)-1_4)
integer(4), parameter :: b1 = a1 + 1_4
integer(4), parameter :: b2 = a2 + 1_4
print *, a1, a2, b1, b2
end program smallest_int
As this is from some rather old code, the problem must have been introduced recently.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just love your tiny reproducers!
Are these the results you expect?
-2147483648 -2147483648 -2147483647 -2147483647
I compiled and ran with the previous Fortran compilers ifx 2023.1.0 and ifort 2021.9.0 and there is no warning message.
I filed a bug report, CMPLRLLVM-50199, asking if this is a bug or a feature? I'll let you know what I find out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. Yes, these are the number to expect in 32 bit signed integer model (-2^31 and -2^31+1). As a1 and a2 are equal, it is surprising to see only a warning for b2. I can still see this, if a1 and a2 are defined elsewhere. So I guess, these values are stored internally as 64bit. Then bit pattern of a1 is different than a2, and in particular a1 is a positive number not fitting into 32 bit signed integer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This erroneous error message is gone with ifx and ifort in the latest release 2024.0. It was released earlier this week. Please give it a try!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page