Bug 176655 - math.h does not declare round, rint
math.h does not declare round, rint
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2005-12-28 13:05 EST by Ulrich Schwenk
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-12-28 13:12:01 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Ulrich Schwenk 2005-12-28 13:05:40 EST
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):

How reproducible:

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){
                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
< 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:
Comment 1 Jakub Jelinek 2005-12-28 13:12:01 EST
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

Note You need to log in before you can comment on or make changes to this bug.