Bug 176655

Summary: math.h does not declare round, rint
Product: [Fedora] Fedora Reporter: Ulrich Schwenk <uli_rgbg>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 4   
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-12-28 18:12:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ulrich Schwenk 2005-12-28 18:05:40 UTC
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:

Comment 1 Jakub Jelinek 2005-12-28 18:12:01 UTC
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