From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30715 invoked by alias); 18 Aug 2006 21:07:51 -0000 Received: (qmail 30619 invoked by uid 48); 18 Aug 2006 21:07:42 -0000 Date: Fri, 18 Aug 2006 21:07:00 -0000 Subject: [Bug tree-optimization/28778] New: strict-aliasing bug X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mrs at apple dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-08/txt/msg01481.txt.bz2 List-Id: mrs $ cat /tmp/t2.cc typedef long GLint; void aglChoosePixelFormat(const GLint *); void find(const int *alistp) { const int *blist; int list[32]; if (alistp) blist = alistp; else { list[3] = 42; /* this store disappears with -fstrict-aliasing */ blist = list; } aglChoosePixelFormat((GLint*)blist); } mrs $ ./xgcc -B./ -S -O1 /tmp/t2.cc -fno-strict-aliasing && grep 42 t2.s li r0,42 mrs $ ./xgcc -B./ -S -O1 /tmp/t2.cc -fstrict-aliasing && grep 42 t2.s mrs $ The store cannot be removed, as the converted pointer can be used inside the aglChoosePixelFormat function to access the value. Since the optimizer can't see that it isn't used, the optimizer must assume it can as the function isn't marked pure. If it had been, then the optimization would be ok. t2.cc.035t.dce1 is the first pass that doesn't have the store, t2.cc.034t.fre has the store. This worked in 3.3, but not 4.0.1. This doesn't work in gcc version 4.2.0 20060815 (experimental) on powerpc-apple-darwin9.0.0d1, nor on i686-apple-darwin8. -- Summary: strict-aliasing bug Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mrs at apple dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28778