From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3759 invoked by alias); 19 May 2015 14:21:46 -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 3707 invoked by uid 55); 19 May 2015 14:21:43 -0000 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/65752] Too strong optimizations int -> pointer casts Date: Tue, 19 May 2015 14:21:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: 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-05/txt/msg01519.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752 --- Comment #18 from rguenther at suse dot de --- On Tue, 19 May 2015, gil.hur at sf dot snu.ac.kr wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752 > > --- Comment #17 from Chung-Kil Hur --- > Hi Richard, > > I modified the example further. > > #include > > int main() { > int x = 0; > uintptr_t xp = (uintptr_t) &x; > uintptr_t i, j; > > for (i = 0; i < xp; i++) { } > j = i; > /* The following "if" statement is never executed because j == xp */ > if (j != xp) { > printf("hello\n"); > j = xp; > } Here j is always xp and thus ... > *(int*)((xp+i)-j) = 15; ... this can (and is) simplified to *(int *)i = 15; making it the same testcase again. > printf("%d\n", x); > } > > The above example does not print "hello", so i can assume that "j = xp" is not > executed. > However, the program prints "0" instead of "15". > Can you explain this?