Bug 98532 - round, roundf not declared in math.h
Summary: round, roundf not declared in math.h
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc   
(Show other bugs)
Version: 8.0
Hardware: i386 Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-07-03 12:57 UTC by Bernhard Ege
Modified: 2016-11-24 14:53 UTC (History)
1 user (show)

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: ---


Attachments (Terms of Use)

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.


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