(j3.2006) Fwd: BOZ incompatiability in Fortran standards
Dan Nagle
danlnagle
Fri Oct 6 16:48:11 EDT 2017
Hi,
With Steve's permission, this may be of interest.
> Begin forwarded message:
>
> From: "Steven G. Kargl" <kargl at troutmask.apl.washington.edu>
> Subject: BOZ incompatiability in Fortran standards
> Date: October 4, 2017 at 13:26:12 MDT
> To: danlnagle at me.com
> Reply-To: kargl at uw.edu
>
> Hi Dan,
>
> I know/suspect that you are busy with finalizing F2015. I just
> noticed a major incompatibility for BOZ in a data-statement between
> F95 and F03 and the later standards F08 and F15. Neither F08
> nor F15 acknowledge this problem. Here are the excerpts:
>
> F95, p. 63
>
> If a data-statement-constant is a boz-literal-constant, the corresponding
> object shall be of type integer. A data-stmt-constant that is a
> boz-literal-constant is treated as if the constant were an int-literal-
> constant with a kind-param that specifies the representation method with
> the largest decimal exponent range supported by the processor.
>
> F2003, p. 89
>
> If a data-stmt-constant is a boz-literal-constant, the corresponding
> variable shall be of type integer. The boz-literal-constant is treated
> as if it were an int-literal-constant with a kind-param that specifies
> the representation method with the largest decimal exponent range
> supported by the processor.
>
> F2008, p. 106
>
> If a data-stmt-constant is a boz-literal-constant, the corresponding
> variable shall be of type integer. The boz-literal-constant is treated
> as if it were converted by the intrinsic function INT (13.7.81) to type
> integer with the kind type parameter of the variable.
>
> F2015, p. 117
>
> If a data-stmt-constant is a boz-literal-constant, the corresponding
> variable shall be of type integer. The boz-literal-constant is treated
> as if it were converted by the intrinsic function INT (16.9.100) to type
> integer with the kind type parameter of the variable.
>
> For this discussion, assume the kind type parameters for two integer
> types are enumerated with 4 and 8. Further, assume that INTEGER(8)
> has a larger decimal exponent range than INTEGER(4). Then, the above
> statements, changes how a Fortran processor interprets
>
> INTEGER(4) I ! Yes, the 4 is nonstandard, but used for discussion.
> DATA I/Z'FFFFFFFFF'/ ! F95/F03 treat BOZ as INTEGER(8),
> PRINT *, I
> END
>
> In F95 and F03, Z'FF' is converted/treated as an INTEGER(8). In F08
> and F15, Z'FF' is converted directly to INTEGER(4).
>
> For gfortran the current behavior gives
>
> troutmask:sgk[248] gfortran6 -static -o z b.f90 -Wall && ./z
> b.f90:2:23:
>
> data i /z'fffffffff'/
> 1
> Error: Arithmetic overflow converting INTEGER(16) to INTEGER(4) at (1).
> This check can be disabled with the option '-fno-range-check'
>
> --
> Steve
> http://troutmask.apl.washington.edu/~kargl/
--
Cheers!
Dan Nagle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.j3-fortran.org/pipermail/j3/attachments/20171006/c1041606/attachment.html>
More information about the J3
mailing list