public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "quantheory at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/58204] [F2008] BOZ literals in the int function should not be treated as unsigned integers
Date: Wed, 04 Sep 2013 02:38:00 -0000	[thread overview]
Message-ID: <bug-58204-4-OvfvQU0vuA@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58204-4@http.gcc.gnu.org/bugzilla/>

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.


  parent reply	other threads:[~2013-09-04  2:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-20 16:21 [Bug fortran/58204] New: Spurious error when using BOZ literal to set an integer quantheory at gmail dot com
2013-09-03 15:25 ` [Bug fortran/58204] " dominiq at lps dot ens.fr
2013-09-04  2:38 ` quantheory at gmail dot com [this message]
2013-09-04  3:45 ` [Bug fortran/58204] [F2008] BOZ literals in the int function should not be treated as unsigned integers kargl at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-58204-4-OvfvQU0vuA@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).