From owner-freebsd-amd64@FreeBSD.ORG Sat Jan 30 15:20:35 2010 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A172106566C; Sat, 30 Jan 2010 15:20:35 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail02.syd.optusnet.com.au (mail02.syd.optusnet.com.au [211.29.132.183]) by mx1.freebsd.org (Postfix) with ESMTP id B95B48FC1B; Sat, 30 Jan 2010 15:20:34 +0000 (UTC) Received: from c122-106-174-165.carlnfd1.nsw.optusnet.com.au (c122-106-174-165.carlnfd1.nsw.optusnet.com.au [122.106.174.165]) by mail02.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o0UFKUbf001197 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 31 Jan 2010 02:20:32 +1100 Date: Sun, 31 Jan 2010 02:20:30 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: gavin@freebsd.org In-Reply-To: <201001301251.o0UCpSEP077706@freefall.freebsd.org> Message-ID: <20100131014341.J78095@delplex.bde.org> References: <201001301251.o0UCpSEP077706@freefall.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: das@freebsd.org, freebsd-standards@freebsd.org, freebsd-amd64@freebsd.org Subject: Re: standards/143358: nearbyint raises spurious inexact exception X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jan 2010 15:20:35 -0000 On Sat, 30 Jan 2010 gavin@freebsd.org wrote: > Synopsis: nearbyint raises spurious inexact exception > Note that a comment in the function itself in lib/msun/src/s_nearbyint.c > does also suggest that this PR is valid, "We save and restore the > floating-point environment to avoid raising an inexact exception." I've > also verified Solaris 10, Linux and FreeBSD 7.2 show the expected behaviour. This seems to be a bug in gcc-4.2, or perhaps a bug in the inline asms. gcc-4.2 still works with -O0, but with -O it removes the entire fesetenv() in nearbyint(). The fegetenv() isn't removed though its result is never used. I didn't get anywhere good trying to fix this, but I got to the following worse place of interest: after replacing the fesetenv(&env) by fesetenv(&xenv) where xenv is an invalidly initialized global variable (all 0's), the fegetenv(&env) corrupted the current environment (looks a bit like xenv was used to initialize the current environment). Removing fesetenv() in other contexts would give larger bugs. Bruce