Bug 441717 - Wrong results for calls to powf(float, float) in ansi-c
Wrong results for calls to powf(float, float) in ansi-c
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: glibc (Show other bugs)
i686 Linux
low Severity medium
: rc
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2008-04-09 12:53 EDT by Thomas Reiter
Modified: 2008-04-09 13:26 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-04-09 13:26:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
preprocessed C-file (19.08 KB, text/plain)
2008-04-09 12:53 EDT, Thomas Reiter
no flags Details

  None (edit)
Description Thomas Reiter 2008-04-09 12:53:58 EDT
Description of problem:

C-programs using the float powf(float, float) function show a behaviour which is
not conform to Ansi-C.

Version-Release number of selected component (if applicable):

$gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)

$rpm -qi glibc-headers
Name        : glibc-headers                Relocations: (not relocatable)
Version     : 2.3.4                             Vendor: Red Hat, Inc.
Release     : 2.39                          Build Date: Wed 12 Sep 2007 18:44:19 BST
Install Date: Fri 16 Nov 2007 03:23:04 GMT      Build Host:
Group       : Development/Libraries         Source RPM: glibc-2.3.4-2.39.src.rpm

How reproducible:

---- bogus.c -----
#include <math.h>
#include <stdio.h>

/* float powf(float, float); */

int main(int argc, char** argv) {
        float x = powf(2.0f, 3.0f);

        printf("%f\n", x);
        return 0;
----- EOF --------

Steps to Reproduce:
1. gcc -save-temps -o bogus -ansi bogus.c -lm
2. ./bogus

Actual results:

Expected results:

Additional info:

If the line /* float powf(float, float); */ is uncommented, the expected result
is reproduced.
Comment 1 Thomas Reiter 2008-04-09 12:53:58 EDT
Created attachment 301849 [details]
preprocessed C-file
Comment 2 Jakub Jelinek 2008-04-09 13:26:15 EDT
That's a user error, not library bug.
powf function isn't ISO C90, only in ISO C99 (and XPG6).
The -ansi switch is equivalent to -std=c89, requesting strict ISO C90 mode. 
<math.h> is an ISO C90 standard covered header, and as such powf doesn't belong
to it.  You need -std=c99 switch to request ISO C99 namespace instead (or
-std=gnu99), or use one of the appropriate feature test macros - in this case e.g.
info libc 'Feature Test Macros'
info gcc
and search for C Dialect Options.

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