Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 441717

Summary: Wrong results for calls to powf(float, float) in ansi-c
Product: Red Hat Enterprise Linux 5 Reporter: Thomas Reiter <t.reiter>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: low    
Version: 5.3   
Target Milestone: rc   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-04-09 17:26:15 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:
Attachments:
Description Flags
preprocessed C-file none

Description Thomas Reiter 2008-04-09 16:53:58 UTC
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:
ls20-bc1-14.build.redhat.com
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:
0.000000

Expected results:
8.000000

Additional info:

If the line /* float powf(float, float); */ is uncommented, the expected result
is reproduced.

Comment 1 Thomas Reiter 2008-04-09 16:53:58 UTC
Created attachment 301849 [details]
preprocessed C-file

Comment 2 Jakub Jelinek 2008-04-09 17:26:15 UTC
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.
-D_ISOC99_SOURCE, -D_XOPEN_SOURCE=600 or -D_GNU_SOURCE.  See
info libc 'Feature Test Macros'
or
info gcc
and search for C Dialect Options.