Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail to build with gcc-14 (-Werror=implicit-function-declaration) #573

Open
orlitzky opened this issue Sep 15, 2024 · 4 comments
Open

Comments

@orlitzky
Copy link
Contributor

With gcc-14, implicit function definitions have become an error by default. There are a few of these in the test suite:

/home/mjo/src/sleef.git/src/libm-tester/tester2simdsp.c: In function 'main':
/home/mjo/src/sleef.git/src/libm-tester/tester2simdsp.c:895:54: error: implicit declaration of function 'isinff' [-Wimplicit-function-declaration]
  895 |           (d >=  sqrt(FLT_MAX) && !(u0 <= 1.0001 || (isinff(t) && t > 0))) ||
/home/mjo/src/sleef.git/src/libm-tester/tester2ld.c: In function 'countULP':
/home/mjo/src/sleef.git/src/libm-tester/tester2ld.c:56:7: error: implicit declaration of function 'isnanl' [-Wimplicit-function-declaration]
   56 |   if (isnanl(c2) && isnanl(d)) return 0;
/home/mjo/src/sleef.git/src/libm-tester/tester2sp.c: In function 'main':
/home/mjo/src/sleef.git/src/libm-tester/tester2sp.c:657:54: error: implicit declaration of function 'isinff' [-Wimplicit-function-declaration]
  657 |           (d >=  sqrt(FLT_MAX) && !(u0 <= 1.0001 || (isinff(t) && t > 0))) ||

I copy/pasted some things to get it working, but usually the issue comes down to a missing #include.

@blapie
Copy link
Collaborator

blapie commented Sep 16, 2024

Hello! Thanks for reporting the error. We can probably easily reproduce locally and surely fix these missing includes.

Btw Gcc 14 is not officially supported in SLEEF yet, so there might be other issues. It probably won't be tested (in CI) unless it can be apt installed from the distributions available via github-hosted runners.

@orlitzky
Copy link
Contributor Author

No problem, both sleef-3.6.1 and gcc-14 are available in Gentoo so our users are testing it :)

@blapie
Copy link
Collaborator

blapie commented Nov 1, 2024

Hi! I admit that it is not ideal to rely on implicit declarations, but I could not reproduce this locally and there does not seem to be an issue in GHA (which now uses gcc 14).
So I'm wondering how to reproduce this issue.
I will look at adding the appropriate includes next week.

@orlitzky
Copy link
Contributor Author

orlitzky commented Nov 3, 2024

Ok, the real problem here is that my linux system doesn't have isinff, and the conditional in misc.h...

#if !defined(__linux__)
#define isinff(x) ((x) == SLEEF_INFINITYf || (x) == -SLEEF_INFINITYf)
#define isinfl(x) ((x) == SLEEF_INFINITYl || (x) == -SLEEF_INFINITYl)
#define isnanf(x) ((x) != (x))
#define isnanl(x) ((x) != (x))
#endif

doesn't define it. An "implicit declaration" occurs when isinff appears in the code for the first time, but it's misleading.

The root cause of this is that GNU libc still defines isinff in its math.h, whereas other libc implementations may not (I'm using musl). From what I'm reading, isinffand isinfl are obsolete because C99/POSIX have standardized an isinf macro that handles the type transparently. Likewise, the two isnan* functions have been superseded by isnan in C99/POSIX.

So, the harder but more correct option would be to migrate away from the separate float/long-double implementations towards isinf and isnan. The easy quick fix would be to adjust the check so that the four functions above get defined whenever they're not already defined (which should not have anything to do with linux per se).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants