From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101253 invoked by alias); 4 Aug 2015 10:07:05 -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 101216 invoked by uid 48); 4 Aug 2015 10:07:02 -0000 From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/66311] [5/6 Regression] Problems with some integer(16) values Date: Tue, 04 Aug 2015 10:07: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: 5.1.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.3 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: 2015-08/txt/msg00174.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66311 Mikael Morin changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mikael at gcc dot gnu.org --- Comment #7 from Mikael Morin --- (In reply to Francois-Xavier Coudert from comment #6) > I tracked the issue to the two calls to wi::from_mpz() and > wide_int_to_tree() in gcc/fortran/trans-const.c:gfc_conv_mpz_to_tree(). > There the mpz value (which is correct) in translated into: > > wide_int_storage = { > val = ([0] = -2, [1] = 0, [2] = 56) > len = 1 > precision = 128 > } > > which appears to be where the -2 comes from. And in wi::from_mpz it probably comes from the mpz_sizeinbytes and mpz_export functions not paying attention to the sign, as stated in the documentation: https://gmplib.org/manual/Integer-Import-and-Export.html > The sign of op is ignored, just the absolute value is exported. An application > can use mpz_sgn to get the sign and handle it as desired. (see Integer > Comparisons) https://gmplib.org/manual/Miscellaneous-Integer-Functions.html#Miscellaneous-Integer-Functions > The sign of op is ignored, just the absolute value is used.