Bug 98532

Summary: round, roundf not declared in math.h
Product: [Retired] Red Hat Linux Reporter: Bernhard Ege <bme>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: high Docs Contact:
Priority: medium    
Version: 8.0CC: fweimer
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-07-03 13:02:56 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 Bernhard Ege 2003-07-03 12:57:20 UTC
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

Comment 1 Jakub Jelinek 2003-07-03 13:02:56 UTC
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.