Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: Brooks Moses <bmoses-nospam@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 29 Mar 2007 00:05:00 -0700
glen herrmannsfeldt wrote:
Brooks Moses wrote:Yes. On the other hand, G77 had an extension of defining BOZ-literals as being a form of integer literal that could be in most (possibly all) places that other forms of integer literals could be used.
Thus, it would interpret real(-Z'00008000') by taking Z'00008000' as an integer constant, negating it, and then converting it to a real number as one would with any other integer constant.
Ok, then -real(Z'00008000'). I was taking the value from the INTEGER
case and changing it to REAL.
Yup. Though g77 handles that the same way -- parsing Z'00008000' as an integer constant, and then passing that integer constant to REAL(). By the time REAL() sees it, the compiler has essentially forgotten that it came from a BOZ-literal.
I'm not exactly sure what you expected real(-Z'00008000') to do under the F2003 rules, but it ought to throw a syntax error due to the minus sign. :)
Without the extraneous minus sign, however, real(Z'00008000') presents a bit of a conundrum for GFortran. G77 has long-standing semantics for what that should mean. F2003, as you point out, also has a definition for what it should mean, and the two versions are quite different.
You could do it based on -std= values.
Indeed, though I don't think that helps much. -std=gnu is supposed to be a reasonable default and a superset of the most recent standard, so which option should it pick?
My personal answer to the conundrum is to hope that nobody uses real(Z'00008000') to mean a real value equivalent to that integer, and to note that Google Code Search doesn't find any instances of it (which I suspect isn't really all that meaningful), and figure that at some point we break it -- but leave I = Z'00008000' working.
IBM OS/360 Fortran and VAX/VMS Fortran allow initializing REAL
variables with Z constants in DATA statements as bit patterns,
no REAL() needed or allowed. (Note that in both cases the ''s
are not used. DATA R/Z80C00000/) gfortran should supply a way
to initialize negative integers and bit pattern reals, for
both backward and forward compatibility.
I think that's a reasonable point, yes. I'm not personally in a position to do anything about it at the moment, however.
- Brooks
--
The "bmoses-nospam" address is valid; no unmunging needed.
.
- References:
- BOZ literal constants, a puzzle for us Standard-loving types.
- From: Toon Moene
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: Steven G. Kargl
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: glen herrmannsfeldt
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: Steven G. Kargl
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: glen herrmannsfeldt
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: Steven G. Kargl
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: glen herrmannsfeldt
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: Brooks Moses
- Re: BOZ literal constants, a puzzle for us Standard-loving types.
- From: glen herrmannsfeldt
- BOZ literal constants, a puzzle for us Standard-loving types.
- Prev by Date: Re: BOZ literal constants, a puzzle for us Standard-loving types.
- Next by Date: Re: BOZ literal constants, a puzzle for us Standard-loving types.
- Previous by thread: Re: BOZ literal constants, a puzzle for us Standard-loving types.
- Next by thread: Re: BOZ literal constants, a puzzle for us Standard-loving types.
- Index(es):