From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27512 invoked by alias); 4 Sep 2013 02:38:39 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 27464 invoked by uid 48); 4 Sep 2013 02:38:35 -0000 From: "quantheory at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.7.3 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: quantheory at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: short_desc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-09/txt/msg00186.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58204 Sean Santos 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 --- 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.