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

Issue with the intrinsic `ibits` called in `integer, parameter` declaration

Jeremie_V_
Beginner
1,261 Views

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

0 Kudos
4 Replies
andrew_4619
Honored Contributor III
1,247 Views

There seem it be several bugs in the recent release with parameter expressions, I am guessing there is some common root cause.

0 Kudos
Jeremie_V_
Beginner
1,221 Views

I tested it also with ifort 17.0.0: same error message.

0 Kudos
andrew_4619
Honored Contributor III
1,211 Views

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.

0 Kudos
Jeremie_V_
Beginner
1,204 Views

Thank you for your test and report.

0 Kudos
Reply