From rse@en1.engelschall.com  Wed Nov  7 04:51:38 2001
Return-Path: <rse@en1.engelschall.com>
Received: from visp.engelschall.com (en4.engelschall.com [62.208.181.48])
	by hub.freebsd.org (Postfix) with ESMTP id 512FC37B418
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  7 Nov 2001 04:51:37 -0800 (PST)
Received: by visp.engelschall.com (Postfix, from userid 1005)
	id 8E3584CE80D; Wed,  7 Nov 2001 13:51:35 +0100 (CET)
Received: by en1.engelschall.com (Sendmail 8.11.0+)
	id fA7Cp6839790; Wed, 7 Nov 2001 13:51:06 +0100 (CET)
Message-Id: <200111071251.fA7Cp6839790@en1.engelschall.com>
Date: Wed, 7 Nov 2001 13:51:06 +0100 (CET)
From: "Ralf S. Engelschall" <rse@en1.engelschall.com>
Reply-To: "Ralf S. Engelschall" <rse@engelschall.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: strdod(3): HUGE_VAL expected in <stdlib.h>, but is in <math.h>
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         31820
>Category:       misc
>Synopsis:       strdod(3): HUGE_VAL expected in <stdlib.h>, but is in <math.h>
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 07 05:00:01 PST 2001
>Closed-Date:    Fri Nov 9 09:06:36 PST 2001
>Last-Modified:  Fri Nov 09 09:07:44 PST 2001
>Originator:     Ralf S. Engelschall
>Release:        FreeBSD 4.4-STABLE i386
>Organization:
Engelschall, Germany.
>Environment:
System: FreeBSD en1.engelschall.com 4.4-STABLE FreeBSD 4.4-STABLE #0: Sun Oct 28 17:45:23 CET 2001 root@en1.engelschall.com:/v/dsk/0/g/src/sys/compile/EN1 i386

>Description:

The manpage of strtod(3) correctly (according to SUSv2) says:

   [...]
   SYNOPSIS
     #include <stdlib.h>
     double strtod(const char *nptr, char **endptr);
   [...]
   RETURN VALUES
   [...]
     If the correct value would cause overflow, plus or minus HUGE_VAL is
     returned [...]

Unfortunately just including <stdlib.h> is not sufficient to get the
definition of HUGE_VAL, because it is defined in our <math.h>. We follow
closely SUSv2 here, so saying that the user should also include <math.h>
is more than what the standard dictates. OTOH always including <math.h>
from <stdlib.h> is also not reasonable, of course.

>How-To-Repeat:

#include <stdlib.h>
#ifndef HUGE_VAL
#error "strtod(3) says it should be defined now"
#endif

>Fix:

I don't know what the best fix for this is. Fact is that SUSv2 says
<stdlib.h> is enough. I don't know whether we nevertheless say "include
also <stdlib.h>" in our FreeBSD version of strtod(3) or whether we hack
our includes so math.h's HUGE_VAL is available through stdlib.h, too.
Someone else has to decide on a correct solution. It certainly is not
a major problem, but a little bit nasty because at least our strtod(3)
does not reflect the FreeBSD reality.

>Release-Note:
>Audit-Trail:

From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To: "Ralf S. Engelschall" <rse@engelschall.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: misc/31820: strdod(3): HUGE_VAL expected in <stdlib.h>, but is in <math.h>
Date: Wed, 7 Nov 2001 11:38:59 -0500 (EST)

 <<On Wed, 7 Nov 2001 13:51:06 +0100 (CET), "Ralf S. Engelschall" <rse@en1.engelschall.com> said:
 
 > Unfortunately just including <stdlib.h> is not sufficient to get the
 > definition of HUGE_VAL, because it is defined in our <math.h>.
 
 Draft 7 of SUSv3 says that implementations may, but are not required
 to, define symbols from <math.h> (and three other headers) in
 <stdlib.h>.
 
 -GAWollman
 

From: Bruce Evans <bde@zeta.org.au>
To: "Ralf S. Engelschall" <rse@engelschall.com>
Cc: <FreeBSD-gnats-submit@FreeBSD.ORG>
Subject: Re: misc/31820: strdod(3): HUGE_VAL expected in <stdlib.h>, but is
 in <math.h>
Date: Fri, 9 Nov 2001 04:18:53 +1100 (EST)

 On Wed, 7 Nov 2001, Ralf S. Engelschall wrote:
 
 > >Description:
 >
 > The manpage of strtod(3) correctly (according to SUSv2) says:
 >
 >    [...]
 >    SYNOPSIS
 >      #include <stdlib.h>
 >      double strtod(const char *nptr, char **endptr);
 >    [...]
 >    RETURN VALUES
 >    [...]
 >      If the correct value would cause overflow, plus or minus HUGE_VAL is
 >      returned [...]
 
 This seems to be just a bug in SUSv2.  The FreeBSD man page just doesn't
 mention _all_ the headers that may be needed for _all_ uses of the function.
 Doing so is very unusual for section [2-3] man pages, since few or none
 of the synopses mention <errno.h> but most of the functions can set errno.
 
 > >Fix:
 >
 > I don't know what the best fix for this is. Fact is that SUSv2 says
 > <stdlib.h> is enough. I don't know whether we nevertheless say "include
 > also <stdlib.h>" in our FreeBSD version of strtod(3) or whether we hack
 > our includes so math.h's HUGE_VAL is available through stdlib.h, too.
 > Someone else has to decide on a correct solution. It certainly is not
 > a major problem, but a little bit nasty because at least our strtod(3)
 > does not reflect the FreeBSD reality.
 
 The C standard doesn't cross-reference either <math.h> or <errno.h> in
 its specification of strtod().  IMO, man pages need such cross-references
 considerably less than paper standards, since they can be grepped.
 
 Bruce
 
State-Changed-From-To: open->closed 
State-Changed-By: wollman 
State-Changed-When: Fri Nov 9 09:06:36 PST 2001 
State-Changed-Why:  
Consensus seems to be that this is not a bug. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31820 
>Unformatted:
