Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.

Invalid use of BOZ

Robert_van_Amerongen
New Contributor III
1,497 Views

Consider the following example:

  PROGRAM tb 
  USE ISO_FORTRAN_ENV
!
  INTEGER(KIND=INT8) :: values(1:3)
!
  values = INT( [ z'11', z'22', z'33'] , KIND=INT8)  ! <<problem line
  write(*,*) values
!
  STOP
  END PROGRAM tb
!

The compiler complains with a warning "warning #6473: Fortran 2015 does not allow boz constant in this context. [Z'11']" similar for the others. The use of BOZ as an argument for the elemental INT function is allowed since Fortran 2003. Therefore, I do not see what I am doing wrong. Any idea? (Compiled with 18.0.0.24)

Robert

0 Kudos
23 Replies
Steve_Lionel
Black Belt Retired Employee
127 Views

Just a comment for those who might make assumptions - BOZ constants are allowed as arguments to selected intrinsics only. If the description of the intrinsic says what it means for a BOZ argument, then it's ok, otherwise it is not.

The list of allowed intrinsics, if I get this correct, is: BGE, BGT, BLE, BLT, CMPLX (X or Y), DBLE, DSHIFTL (I or J), DSHIFTR (I or J), IAND, IEOR, INT (A), IOR, MERGE_BITS, REAL (A).

Robert_van_Amerongen
New Contributor III
127 Views

Andrew_4619 (#16) is right if he states that there are many other means to solve the problem. FortranFan (#19) give one of these: the data statement. I stil prefer the original code in my post (#1), but I am afraid that this will not appear in any standard in the future. It is as it is.

Thanks for the contributions.

Robert

jimdempseyatthecove
Black Belt
127 Views

While I agree that Z"101" should be flagged as out of range for an integer(1), Z"81" should not (nor Z"FF" or any hex less than Z"FF").

When a programmer uses a debugger and views an integer as Hex, or uses a Hex calculator, there are no "negative" numbers. Enter -3 and the display shows FFFFFFFFFFFFFFFD.

I do not think that Fortran should go out of its way as having oddball behavior.

Jim Dempsey

Reply