| Summary: | strdod(3): HUGE_VAL expected in <stdlib.h>, but is in <math.h> | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Ralf S. Engelschall <rse> |
| Component: | misc | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.4-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
<<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 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 Consensus seems to be that this is not a bug. |
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. 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. How-To-Repeat: #include <stdlib.h> #ifndef HUGE_VAL #error "strtod(3) says it should be defined now" #endif