POSIX claims that powl(3) should be defined via math.h/libm ( http://pubs.opengroup.org/onlinepubs/9699919799/functions/pow.html) with std=c99, but unfortunately this appears to be broken on FreeBSD 10-STABLE/11-CURRENT. If I remove the "#if _DECLARE_C99_LDBL_MATH" guard from math.h, things compile more cleanly (it just emits a warning about loss in precision because of the imprecise functions). This guard should probably have a !defined(__cplusplus) check added to it. Before: % clang -std=iso9899:1999 -lm -o /root/powl_undeclared /root/powl_undeclared.c /root/powl_undeclared.c:9:41: warning: implicitly declaring library function 'powl' with type 'long double (long double, long double)' printf("powl(%Lf, %Lf) = %Lf\n", a, b, powl(a, b)); ^ /root/powl_undeclared.c:9:41: note: please include the header <math.h> or explicitly provide a declaration for 'powl' 1 warning generated. /tmp/powl_undeclared-252fa5.o: In function `main': /root/powl_undeclared.c:(.text+0x4e): warning: powl has lower than advertised precision % gcc -std=c99 -lm -o /root/powl_undeclared /root/powl_undeclared.c /root/powl_undeclared.c: In function 'main': /root/powl_undeclared.c:9: warning: implicit declaration of function 'powl' /root/powl_undeclared.c:9: warning: incompatible implicit declaration of built-in function 'powl' /tmp//ccSJGxdD.o: In function `main': powl_undeclared.c:(.text+0x54): warning: powl has lower than advertised precision % gcc46 -std=c99 -lm -o /root/powl_undeclared /root/powl_undeclared.c /root/powl_undeclared.c: In function 'main': /root/powl_undeclared.c:9:2: warning: implicit declaration of function 'powl' [-Wimplicit-function-declaration] /root/powl_undeclared.c:9:41: warning: incompatible implicit declaration of built-in function 'powl' [enabled by default] /tmp//ccmC02s8.o: In function `main': powl_undeclared.c:(.text+0x54): warning: powl has lower than advertised precision % gcc -std=iso9899:1999 -lm -o /root/powl_undeclared /root/powl_undeclared.c /root/powl_undeclared.c: In function 'main': /root/powl_undeclared.c:9: warning: implicit declaration of function 'powl' /root/powl_undeclared.c:9: warning: incompatible implicit declaration of built-in function 'powl' /tmp//ccGtRDWg.o: In function `main': powl_undeclared.c:(.text+0x54): warning: powl has lower than advertised precision % gcc46 -std=iso9899:1999 -lm -o /root/powl_undeclared /root/powl_undeclared.c /root/powl_undeclared.c: In function 'main': /root/powl_undeclared.c:9:2: warning: implicit declaration of function 'powl' [-Wimplicit-function-declaration] /root/powl_undeclared.c:9:41: warning: incompatible implicit declaration of built-in function 'powl' [enabled by default] /tmp//ccjUVEX8.o: In function `main': powl_undeclared.c:(.text+0x54): warning: powl has lower than advertised precision After: % gcc46 -std=iso9899:1999 -lm -o /root/powl_undeclared /root/powl_undeclared.c /tmp//ccMsjZpJ.o: In function `main': powl_undeclared.c:(.text+0x54): warning: powl has lower than advertised precision % clang -std=iso9899:1999 -lm -o /root/powl_undeclared /root/powl_undeclared.c /tmp/powl_undeclared-ed9797.o: In function `main': /root/powl_undeclared.c:(.text+0x4e): warning: powl has lower than advertised precision % gcc -std=iso9899:1999 -lm -o /root/powl_undeclared /root/powl_undeclared.c /tmp//ccFvfEeJ.o: In function `main': powl_undeclared.c:(.text+0x54): warning: powl has lower than advertised precision
Created attachment 145432 [details] patch for math.h.diff
This appears to be a question about compliance to the C99 standard. Change the component accordingly.
(In reply to Steve Kargl from comment #2) > This appears to be a question about compliance to the C99 standard. > Change the component accordingly. LGTM!
A commit references this bug: Author: kargl Date: Sat Aug 9 15:53:41 UTC 2014 New revision: 269758 URL: http://svnweb.freebsd.org/changeset/base/269758 Log: When r255294 was committed, it exposed the symbols lgammal, powl, and tgammal in libm. These functions are part of ISO/IEC 9899:1999 and their prototypes should have been moved into the appropriate __ISO_C_VISIBLE >= 1999 section. After moving the prototypes, remnants of r236148 can be removed. PR: standards/191754 Reviewed by: bde Changes: head/lib/msun/src/math.h
Thanks for the PR.
(In reply to Steve Kargl from comment #5) > Thanks for the PR. Thanks for the fix :)... Should this be MFCed?