- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code demonstrates oddities in the checks of bit intrinsic arguments:
program p
integer :: i
logical, parameter :: a(*) = [(btest(8_4,i), i=-1,-1)]
integer, parameter :: b(*) = [(ibclr(8_4,i), i=-1,-1)]
integer, parameter :: c(*) = [(ibset(8_4,i), i=-1,-1)]
logical, parameter :: d(*) = [(btest(8_4,i), i=32,32)]
integer, parameter :: e(*) = [(ibclr(8_4,i), i=32,32)]
integer, parameter :: f(*) = [(ibset(8_4,i), i=32,32)]
integer, parameter :: g(*) = [(ibset(8_4,i), i=33,33)]
end
ifort/2021.6.0 and ifx/2022.1.0 produce:
ifort-check_bits.f90(3): error #6331: The POS argument to BTEST, IBITS, IBCLR, or IBSET must be less than BIT_SIZE.
logical, parameter :: a(*) = [(btest(8_4,i), i=-1,-1)]
---------------------------------^
ifort-check_bits.f90(4): error #6331: The POS argument to BTEST, IBITS, IBCLR, or IBSET must be less than BIT_SIZE.
integer, parameter :: b(*) = [(ibclr(8_4,i), i=-1,-1)]
---------------------------------^
ifort-check_bits.f90(5): error #6331: The POS argument to BTEST, IBITS, IBCLR, or IBSET must be less than BIT_SIZE.
integer, parameter :: c(*) = [(ibset(8_4,i), i=-1,-1)]
---------------------------------^
ifort-check_bits.f90(9): error #6331: The POS argument to BTEST, IBITS, IBCLR, or IBSET must be less than BIT_SIZE.
integer, parameter :: g(*) = [(ibset(8_4,i), i=33,33)]
---------------------------------^
compilation aborted for ifort-check_bits.f90 (code 1)
So the first error messages are misleading, some checks are off-by one: bit_size(8_4) = 32, not 33.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
pos(Input) Must be of type integer. It must not be negative and it must be less than BIT_SIZE(i).
The rightmost (least significant) bit of i is in position 0.
So all the errors are correct 0,31 only are valid, the message could be better "out of range" might be more accurate
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page