From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16902 invoked by alias); 27 Dec 2013 18:10:30 -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 16864 invoked by uid 48); 27 Dec 2013 18:10:24 -0000 From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/59604] Constant comparisons with -fno-range-check and int(z'...') Date: Fri, 27 Dec 2013 18:10: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.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl 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-Flags: X-Bugzilla-Changed-Fields: cc 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-12/txt/msg02264.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59604 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #2 from kargl at gcc dot gnu.org --- (In reply to Thomas Koenig from comment #1) > TRANSFER gets this right. It is unclear what you mean here. A simplified program that removes the complication of the IO and ISO C binding is program test if (int(z'FFFFFFFF') /= -1) call abort end program test % gfc4x -o z -fno-range-check -fdump-tree-original a.f90 % ./z Program aborted. Backtrace: #0 0x4807A01C #1 0x4807B8CF #2 0x48134C17 #3 0x8048792 in MAIN__ at a.f90:0 Abort (core dumped) %cat a.f90.003t.orginal test () { _gfortran_abort (); L.1:; } main (integer(kind=4) argc, character(kind=1) * * argv) { static integer(kind=4) options.0[9] = {68, 1023, 0, 0, 1, 1, 0, 0, 31}; _gfortran_set_args (argc, argv); _gfortran_set_options (9, &options.0[0]); test (); return 0; } I believe the problem lies in gfc_simplify_int. From what I can tell, there is never a conversion of a boz to an integer, until we reach code generation. The call chain is gfc_simplify_int -> simplify->intconv -> gfc_convert_constant -> gfc_int2int. By the time we reach gfc_int2int, the boz should have been converted to the integer, but isn't. Now, if we compare gfc_simplify_int to gfc_simplify_real, we see in gfc_simplify_real, if (convert_boz (e, kind) == &gfc_bad_expr) return &gfc_bad_expr; where convert_boz will do an explicit conversion of a boz to a real type. There isn't a similar functionality for integer.