http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58204

Sean Santos <quantheory at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Spurious error when using   |[F2008] BOZ literals in the
                   |BOZ literal to set an       |int function should not be
                   |integer                     |treated as unsigned
                   |                            |integers

--- Comment #2 from Sean Santos <quantheory at gmail dot com> ---
Yes, re-reading the Fortran 95 standard, it does look like what gfortran is
doing follows the standard for a BOZ in a DATA statement, but BOZ is not
allowed in an int, so Fortran 95 isn't relevant for the particular test program
in comment 0. In the Fortran 2008 standard, it seems like this is still a bug,
for the reasons I mentioned.

Fortran 2003 is weird. If the BOZ is in the "int" function, it is supposed to
be treated as an integer constant, much like in a Fortran 95 data statement. If
the BOZ is in a "real" function, it is treated as a bit pattern, just like in
Fortran 2008. So actually, you could argue that gfortran is OK for Fortran 2003
as well.

I'm marking this as Fortran 2008, accordingly.

My main motivation for raising this issue at all is that this is one of several
reasons that you have to really jump through hoops to set a real to IEEE
infinity or NaN.

In fact, this seems to be the simplest way to create a constant for
double-precision -Infinity without using "-fno-range-check":

integer(8), parameter :: ninf_bits = &
     ibset(int(Z'7FF0000000000000',8),bit_size(1_8)-1)
real(8), parameter :: neginf = transfer(ninf_bits,1._8)

It's not the worst thing ever, but it's more than a little silly.

Reply via email to