Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Sep 2002 16:09:49 -0700 (PDT)
From:      Archie Cobbs <archie@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/43544: Bogus definition of HUGE_VAL in <math.h>
Message-ID:  <200209302309.g8UN9nWh083274@panther.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         43544
>Category:       bin
>Synopsis:       Bogus definition of HUGE_VAL in <math.h>
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 30 16:10:05 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Archie Cobbs
>Release:        FreeBSD 5.0-CURRENT sparc64
>Organization:
Packet Design
>Environment:
System: FreeBSD panther.freebsd.org 5.0-CURRENT FreeBSD 5.0-CURRENT #7: Tue Sep 17 18:14:25 PDT 2002 peter@panther.freebsd.org:/s/src/sys/sparc64/compile/PANTHER sparc64


>Description:

	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.

>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

>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??

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209302309.g8UN9nWh083274>