From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6553 invoked by alias); 29 Feb 2012 07:40:09 -0000 Received: (qmail 6542 invoked by uid 22791); 29 Feb 2012 07:40:06 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 29 Feb 2012 07:39:49 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/52428] New: [RFC] I/O: READING of "-huge()-1": Integer overflow Date: Wed, 29 Feb 2012 08:13:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-02/txt/msg02762.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52428 Bug #: 52428 Summary: [RFC] I/O: READING of "-huge()-1": Integer overflow Classification: Unclassified Product: gcc Version: unknown URL: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=65825 1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org CC: jvdelisle@gcc.gnu.org As reported at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=658251 For I/O, reading an integer with value -huge()-1 gives an overflow error. While that is acceptable based on the Fortran numerical model (cf. Fortran 2008, "13.4 Numeric models"), where the valid integer numbers stretch from -huge() to huge(), it is rather irritating that one can write (WRITE, PRINT) those numbers but not READ them back in. Except for Fortran's numerical model, the number looks valid to me as the sign belongs to the number and is not an unary operator applied afterwards. For integer I/O, one reads a "signed-digit-string" (R409). For the source code, something similar applies: Also there, one does *not* have an unary minus operator applied to the positive string literal but: R406 signed-int-literal-constant is [ sign ] int-literal-constant Only Fortran's numerical model is violated. Contrary to I/O, a error is printed, which can be overruled using -fno-range-check (and that flag is often but not always mentioned). EXPECTED: Be more generous at run time and allow this number for integer input.