Bug 98532 - round, roundf not declared in math.h
round, roundf not declared in math.h
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
8.0
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-07-03 08:57 EDT by Bernhard Ege
Modified: 2007-04-18 12:55 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-07-03 09:02:56 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Bernhard Ege 2003-07-03 08:57:20 EDT
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 09:02:56 EDT
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.

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