From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 Description of problem: Compiling any program using round or roundf will show abnormal behaviour even when including math.h. Problem is that round and roundf (and probably more) are not declared in any of the header files. Gcc silently ignores the problem per default, but adding -Wall, the real cause of the problem is shown. The following small program shows the error: #include <stdio.h> #include <math.h> int main(void) { float n,r; n=19.5; r=round(n); printf("%f %f\n",n,r); return 0; } Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. Create any program using round/roundf and #include <math.h> 2. Compile and link with -lm 3. See output from round function call be completely messed up. Actual Results: [bme@overmind bme]$ gcc -Wall test.c -o test -lm test.c: In function `main': test.c:6: warning: implicit declaration of function `round' [bme@overmind bme]$ ./test 19.500000 32768.000000 Expected Results: [bme@overmind bme]$ gcc -Wall test.c -o test -lm [bme@overmind bme]$ ./test 19.500000 20.000000 Additional info: [bme@overmind bme]$ rpm -q --whatprovides /usr/include/math.h glibc-devel-2.3.2-4.80.6 [bme@overmind bme]$ rpm -q --whatprovides /lib/libm.so.6 glibc-2.3.2-4.80.6
Please see info libc on Feature Set Macros. Particularly, round* functions are ISO C99 addition, so you need to compile with either of -std=c99, -std=gnu99, -D_ISOC99_SOURCE or -D_GNU_SOURCE.