- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- « Previous
-
- 1
- 2
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »