Bug 43544

Summary: Bogus definition of HUGE_VAL in <math.h>
Product: Base System Reporter: Archie Cobbs <archie>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   

Description Archie Cobbs freebsd_committer freebsd_triage 2002-10-01 00:10:05 UTC
	The defintion of HUGE_VAL in <math.h> looks like this:

	    extern char __infinity[];
	    #define HUGE_VAL        (*(double *) __infinity)

	This causes compiler warnings when using -Wcast-align:

	    xx.c: In function `main':
	    xx.c:9: warning: cast increases required alignment of target type

	There is an additional problem: there are two versions of "math.h"
	in the FreeBSD tree:

		src/include/math.h
		src/lib/msun/src/math.h 

	Contrary to what you might think, src/include/math.h is NOT the
	one that gets installed into /usr/include during installation.

Fix: 

I tried to fix this with these commits:

		http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/msun/src/math.h.diff?r1=1.14&r2=1.15
		http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/i386/gen/infinity.c.diff?r1=1.6&r2=1.7
		http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/alpha/gen/infinity.c.diff?r1=1.3&r2=1.4
		http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/ia64/gen/infinity.c.diff?r1=1.2&r2=1.3
		http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/sparc64/gen/infinity.c.diff?r1=1.3&r2=1.4

	but for some completely screwed reason, the libc compilation fails
	because of bogus #include paths, and I had to back out my commit.

	I have no idea how to fix this... why the heck are there two versions
	of math.h??
How-To-Repeat: 
	Logon to a sparc or alpha FreeBSD machine. Then do this:

	    $ cat > xx.c

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

	    int
	    main(int ac, char **av)
	    {
		    double x = 0;

		    printf("%d\n", x == HUGE_VAL);
		    return (0);
	    }
	    ^D
	    $ cc -Wcast-align -o xx xx.c
Comment 1 Archie Cobbs freebsd_committer freebsd_triage 2002-10-31 23:07:07 UTC
State Changed
From-To: open->closed

Fixed in -current by these revisions: 

/home/ncvs/src/lib/libc/alpha/gen/infinity.c,v  <--  infinity.c 
new revision: 1.6; previous revision: 1.5 
/home/ncvs/src/lib/libc/i386/gen/infinity.c,v  <--  infinity.c 
new revision: 1.9; previous revision: 1.8 
/home/ncvs/src/lib/libc/ia64/gen/infinity.c,v  <--  infinity.c 
new revision: 1.5; previous revision: 1.4 
/home/ncvs/src/lib/libc/sparc64/gen/infinity.c,v  <--  infinity.c 
new revision: 1.6; previous revision: 1.5 
/home/ncvs/src/lib/msun/src/math.h,v  <--  math.h 
new revision: 1.20; previous revision: 1.19