From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121097 invoked by alias); 3 Sep 2015 08:59:41 -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 120999 invoked by uid 48); 3 Sep 2015 08:59:37 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/67442] [5/6 Regression] GCC 5.2.0 on x86_64 creates invalid address on specific array index calculation through pointer Date: Thu, 03 Sep 2015 08:59:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 5.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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-09/txt/msg00234.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67442 --- Comment #4 from Richard Biener --- That is, tree wide_int_to_tree (tree type, const wide_int_ref &pcst) { ... unsigned int prec = TYPE_PRECISION (type); signop sgn = TYPE_SIGN (type); ... wide_int cst = wide_int::from (pcst, prec, sgn); is according to its docs "The value is extended from its precision according to the sign of the type", but that isn't what anyone would expect. IIRC the wide_int_ref doesn't have a "sign", so we can't do the correct thing. So IMHO we should require pcst.get_precision () == prec and maybe offer an overload tree wide_int_to_tree (tree type, const wide_int_ref &pcst, signop sgn); that can specify the sign of pcst (or maybe require that always...).