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

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

Jeremie_V_
Beginner
352 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 II
338 Views

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

Jeremie_V_
Beginner
312 Views

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

andrew_4619
Honored Contributor II
302 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.

Jeremie_V_
Beginner
295 Views

Thank you for your test and report.

Reply