From owner-freebsd-current Thu Nov 14 17:38: 4 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B01237B401 for ; Thu, 14 Nov 2002 17:38:03 -0800 (PST) Received: from HAL9000.homeunix.com (12-232-220-15.client.attbi.com [12.232.220.15]) by mx1.FreeBSD.org (Postfix) with ESMTP id D748043E77 for ; Thu, 14 Nov 2002 17:38:02 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.6/8.12.5) with ESMTP id gAF1bp2q012212; Thu, 14 Nov 2002 17:37:51 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.6/8.12.5/Submit) id gAF1bpPI012211; Thu, 14 Nov 2002 17:37:51 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Date: Thu, 14 Nov 2002 17:37:50 -0800 From: David Schultz To: TOMITA Yoshinori Cc: Thomas David Rivers , FreeBSD-current@FreeBSD.ORG Subject: Re: gcc 3.2.1 optimization bug ? Message-ID: <20021115013750.GA12079@HAL9000.homeunix.com> Mail-Followup-To: TOMITA Yoshinori , Thomas David Rivers , FreeBSD-current@FreeBSD.ORG References: <200211111355.gABDt2g55397@lakes.dignus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Thus spake TOMITA Yoshinori : > But unfortunately, that ugly code was contained in our inhouse library > written by someone. > It took me two days to debug and find out where difference comes from > between gcc-2.95.4 and gcc-3.2.1. You can work around the problem by disabling -fschedule-insns or -fstrict-aliasing, both of which are turned on by -O2. The latter option is the more direct cause of your problem, but for some reason only the combination of the two seems to generate incorrect output on i386. Of course what you really ought to do is fix the code. C99 makes no provisions for type punning, to my knowledge. However, the GCC project officially blesses two practices: - referring to any object through a character pointer - punning the elements of a union Note that the latter only works if you directly refer to the union directly, rather than through a pointer. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message