From owner-freebsd-java Sat Feb 15 21:22: 0 2003 Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A23FD37B401; Sat, 15 Feb 2003 21:21:59 -0800 (PST) Received: from HAL9000.homeunix.com (12-233-57-224.client.attbi.com [12.233.57.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0B8F343F75; Sat, 15 Feb 2003 21:21:59 -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 h1G5LwQb001545; Sat, 15 Feb 2003 21:21:58 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.6/8.12.5/Submit) id h1G5LwX0001544; Sat, 15 Feb 2003 21:21:58 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Date: Sat, 15 Feb 2003 21:21:58 -0800 From: David Schultz To: Huang wen hui Cc: java@FreeBSD.ORG, stable@FreeBSD.ORG Subject: Re: Optimization problem (Re: Math.pow bug for jdk1.3.1-p8 ?) Message-ID: <20030216052158.GA1488@HAL9000.homeunix.com> Mail-Followup-To: Huang wen hui , java@FreeBSD.ORG, stable@FreeBSD.ORG References: <3E4C9DDD.4040204@gddsn.org.cn> <20030215.175421.1015281127.shudo@localhost> <20030216014802.A10817@misty.eyesbeyond.com> <20030216.005020.894433699.shudo@localhost> <3E4E7728.8030803@gddsn.org.cn> <3E4E86B8.2040608@gddsn.org.cn> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3E4E86B8.2040608@gddsn.org.cn> Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Thus spake Huang wen hui : > This is a simple one: > > #include > > #define __LO(x) *(int*)&x ^^^^^^^^^^^^ The failure of this macro to work as expected is not a compiler bug. The C language makes no provisions to support type punning, and the above is not legal C. When you use gcc -f-string-aliasing -fschedule-insns (which are enabled by -O2), your code might, in fact, break. (I haven't actually observed this for 32-bit quantities and smaller.) The gcc-blessed workaround is to use direct unions (and not pointers thereto), but even that is technically unportable. FWIW, when I last checked, Sun only guaranteed that the JVM would compile with a specific version of gcc and no optimization. That's one of the reasons its performance on ia64 is so terrible. I'm guessing that optimization is unsupported for Sun's JVM for the same reason that it is unsupported in Berkeley Logo; specifically, it probably tries to perform some clever stack manipulation tricks. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message