cmath vs. math.h vs isfinite
Thomas Klausner <[email protected]>
| Newsgroups | gmane.os.netbsd.devel.toolchain |
|---|---|
| Message-ID | <[email protected]> |
Hi!
cython 3.3.0 uncovered a problem in our headers, at least compared to
other systems.
Using this test program test.cc:
#include <cmath>
#include <math.h>
#include <cstdio>
#include <cstdlib>
int main() {
if (isfinite(0.0)) {
printf("finite\n");
}
exit(0);
}
# make test
c++ -O2 -o test test.cc
test.cc: In function 'int main()':
test.cc:6:7: error: 'isfinite' was not declared in this scope; did you mean 'std::isfinite'?
6 | if (isfinite(0.0)) {
| ^~~~~~~~
| std::isfinite
In file included from test.cc:1:
/usr/include/g++/cmath:1142:5: note: 'std::isfinite' declared here
1142 | isfinite(_Tp)
| ^~~~~~~~
*** Error code 1
but when I remove <cmath> and only include <math.h> it's fine:
# make test
c++ -O2 -o test test.cc
#
I tried the same program on godbolt.org and do not see the same issue
- as long as math.h is included, a plain isfinite is fine; only if
<cmath> is included alone, it doesn't work.
Is there some standard lawyering that makes NetBSD ok, or is this
something that should be fixed in our headers?
Thomas