From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de-DE; rv:1.7.10) Gecko/20050909 Fedora/1.0.6-1.2.fc4 Firefox/1.0.6 Description of problem: #include <math.h> in a C-program does not declare round() and rint() Version-Release number of selected component (if applicable): glibc-headers-2.3.5-10.3 How reproducible: Always Steps to Reproduce: :~ >cat roundtest.c #include <math.h> #include <stdlib.h> #include <stdio.h> /*This declaration should be in math.h*/ double round(double); double rint(double); int main() { double i,x,y,z; for (i=0;i<4;i+=0.01){ x=round(i); y=rint(i); z=i; printf("rint: %.4f, round: %.4f, real: %.4f\n",y,x,z); } return 0; } :~ >gcc -ansi -Wall -lm roundtest.c (compiles and runs all right) :~ >diff roundtest.c roundtest_modified.c 5,7d4 < double round(double); < double rint(double); < :~ >gcc -ansi -Wall -lm roundtest_modified.c roundtest_modified.c: In Funktion �main�: roundtest_modified.c:8: Warnung: implizite Deklaration der Funktion �round� roundtest_modified.c:9: Warnung: implizite Deklaration der Funktion �rint� (warning reads in english "implicit Declaration of fucntion ...", a.out crashes) Actual Results: result is described above; in short: declaring the functions myself leeds to working executable doing like the manpage says and just including math.h leeds to stack-smashing executable Additional info:
Please RTFM info libc 'Feature Test Macros' Both rint and round were introduced in ISO C99 (or are GNU extensions), so you should use one of: gcc -std=c99 -Wall roundtest_modified.c -lm gcc -std=gnu99 -Wall roundtest_modified.c -lm gcc -D_ISOC99_SOURCE -Wall roundtest_modified.c -lm gcc -D_GNU_SOURCE -Wall roundtest_modified.c -lm