- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear,
I tried to use the intrinsic `ibits` when declaring a `parameter` integer in a program. Here is an example:
```fortran
program test
use, intrinsic :: iso_fortran_env, only: int16, int32
implicit none
integer(int32), parameter :: nmh_m1 = int(z'F0D9649B', int32 )
integer(int16), parameter :: nmh_m1_16 = ibits( nmh_m1, 16, 16 )
end program
```
When I tried to compile it with Intel ifort 2021.4.0 (ifort test.f90), I got the following ERROR message:
```
test.f90(7): error #6367: IN IBITS evaluation, POS + LEN is greater than BIT_SIZE.
integer(int16), parameter :: nmh_m1_16 = ibits( nmh_m1, 16, 16 )
-------------------------------------------------------------^
test.f90(7): warning #6046: The INTEGER(KIND=2) value is out-of-range.
integer(int16), parameter :: nmh_m1_16 = ibits( nmh_m1, 16, 16 )
------------------------------------------^
compilation aborted for test.f90 (code 1)
```
I don't understand this message, because `bit_size` of `nmh_m1` is 32, and 16 + 16 is also equal to 32.
What do I miss?
In advance thank you.
Yours sincerely,
Jeremie
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There seem it be several bugs in the recent release with parameter expressions, I am guessing there is some common root cause.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tested it also with ifort 17.0.0: same error message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But the assignment
nmh_m1_16 = ibits( nmh_m1, 16, 16 ) generates no errors. Your code is valid for me for what it is worth it is a bug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your test and report.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page