From nobody@FreeBSD.org  Fri Aug 19 00:09:06 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 815C716A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 19 Aug 2005 00:09:06 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 538C543D46
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 19 Aug 2005 00:09:06 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j7J096bE001444
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 19 Aug 2005 00:09:06 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j7J095UC001443;
	Fri, 19 Aug 2005 00:09:05 GMT
	(envelope-from nobody)
Message-Id: <200508190009.j7J095UC001443@www.freebsd.org>
Date: Fri, 19 Aug 2005 00:09:05 GMT
From: Haejoong Lee <haepal@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: nearbyint always returns nan
X-Send-Pr-Version: www-2.3

>Number:         85101
>Category:       i386
>Synopsis:       [libm] nearbyint always returns nan
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    das
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 19 00:10:15 GMT 2005
>Closed-Date:    Mon Dec 17 07:06:50 UTC 2007
>Last-Modified:  Mon Dec 17 07:06:50 UTC 2007
>Originator:     Haejoong Lee
>Release:        5.4-RELEASE, 5.4-RC4
>Organization:
Linguistic Data Consortium
>Environment:
FreeBSD mayor.ldc.upenn.edu 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Sun May  8 10:21:06 UTC 2005     root@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
FreeBSD katz.ldc.upenn.edu 5.4-RC4 FreeBSD 5.4-RC4 #0: Tue May  3 21:41:34 EDT 2005     root@katz.ldc.upenn.edu:/usr/src/sys/i386/compile/DEVSMP  i386

>Description:
The following program prints out "nan"'s instead of some numbers.

#include <stdio.h>
#include <math.h>

int main()
{
  double x = -100.0;
  for (; x < 100.0; x+= 0.1)
    printf("%f\n", nearbyint(x));
}


I also saw this happening on 5.3-STABLE, but it didn't happen 5.4-STABLE amd64.

>How-To-Repeat:
Compile the program above and run it.
>Fix:
      
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: das 
State-Changed-When: Thu Jan 4 00:20:42 UTC 2007 
State-Changed-Why:  
I know what the problem is and I'll work on it.  As a workaround, 
turn off -msse or use -O0 when compiling libm. 


Responsible-Changed-From-To: freebsd-i386->das 
Responsible-Changed-By: das 
Responsible-Changed-When: Thu Jan 4 00:20:42 UTC 2007 
Responsible-Changed-Why:  
I know what the problem is and I'll work on it.  As a workaround, 
turn off -msse or use -O0 when compiling libm. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85101 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: i386/85101: commit references a PR
Date: Sat,  6 Jan 2007 21:46:41 +0000 (UTC)

 das         2007-01-06 21:46:23 UTC
 
   FreeBSD src repository
 
   Modified files:
     lib/msun/amd64       fenv.h 
     lib/msun/i387        fenv.h 
   Log:
   Fix a problem relating to fesetenv() clobbering i387 register stack.
   
   Details: As a side-effect of restoring a saved FP environment,
   fesetenv() overwrites the tag word, which indicates which i387
   registers are in use.  Normally this isn't a problem because
   the calling convention requires the register stack to be empty
   on function entry and exit.  However, fesetenv() is inlined, so we
   need to tell gcc explicitly that the i387 registers get clobbered.
   
   PR:     85101
   
   Revision  Changes    Path
   1.6       +12 -1     src/lib/msun/amd64/fenv.h
   1.6       +12 -1     src/lib/msun/i387/fenv.h
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: analyzed->patched 
State-Changed-By: das 
State-Changed-When: Sat Jan 6 21:50:34 UTC 2007 
State-Changed-Why:  
Fixed in: 
1.6       +12 -1     src/lib/msun/amd64/fenv.h 
1.6       +12 -1     src/lib/msun/i387/fenv.h 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85101 
State-Changed-From-To: patched->closed 
State-Changed-By: das 
State-Changed-When: Mon Dec 17 07:05:55 UTC 2007 
State-Changed-Why:  
It looks like bde MFC'd this to RELENG_6 months ago. (Thanks, Bruce!) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=85101 
>Unformatted:
