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: | glibc | Assignee: | 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: |
|
||||||
Created attachment 301849 [details]
preprocessed C-file
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. |
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.