Summary: | Multiple flaws in decimal floating-point arithmetic conversions fixed | ||
---|---|---|---|
Product: | gcc | Reporter: | beebe |
Component: | c | Assignee: | Janis Johnson <janis> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | gcc-bugs, janis |
Priority: | P3 | ||
Version: | 4.3.0 | ||
Target Milestone: | --- | ||
Host: | x86_64-unknown-linux-gnu | Target: | x86_64-unknown-linux-gnu |
Build: | x86_64-unknown-linux-gnu | Known to work: | |
Known to fail: | Last reconfirmed: | 2006-11-29 02:45:38 |
Description
beebe
2006-11-29 02:02:52 UTC
422c424 < typedef float DFtype __attribute__ ((mode (DF))); --- > typedef double DFtype __attribute__ ((mode (DF))); 424c426 < typedef float XFtype __attribute__ ((mode (XF))); --- > typedef long double XFtype __attribute__ ((mode (XF))); This part really should not matter as mode tells the compiler what the real type is. > /* strtold is declared in <stdlib.h> only for C99. */
> extern long double strtold (const char *, char **);
> #define STR_TO_BFP strtold
Well use -std=gnu99 then.
PS the testcase violates C aliasing rules. Ben just mentioned this PR to me, I hadn't seen it before. I'm working on a patch to support TFmode for powerpc*-linux, and I'll talk to HJ about proper support for XFmode. Initially we didn't support long double because we were testing on powerpc64-linux where there was no C library support for 128-bit long double. Now that there is, we can support it. Thanks for the test, I'll modify it so it doesn't violate aliasing rules and add it to the testsuite. Please report other problems you find. Why use "%.9e", "%.17e", and "%.36Le" to write the binary float values to a string, instead of using lengths of FLT_DIG, DBL_DIG, and LDBL_DIG? For i686-linux those are 6, 15, and 18. Subject: Bug 30013 Author: janis Date: Tue Sep 11 01:11:16 2007 New Revision: 128361 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128361 Log: gcc/ PR c/30013 * config/dfp-bit.c: Don't skip TFmode conversions; move strto* declarations to top. (DFP_TO_BFP): Use for either XFmode or TFmode. (BFP_TO_DFP): Use for either XFmode or TFmode; always use cast of BFP_VIA_TYPE. * config/dfp-bit.h: Include float.h. (LONG_DOUBLE_HAS_XF_MODE, LONG_DOUBLE_HAS_TF_MODE): Define if long double is one of these modes, rather than using LIBGCC_HAS_*F_MODE which doesn't mean the same thing. (BFP_KIND): Use 4 to mean TFmode. (BFP_FMT): Specify the number of decimal digits based on the number of mantissa digits. (BFP_VIA_TYPE): Binary float type to use as cast for sprintf. (BFP_TO_DFP, DFP_TO_BFP): Define names for TFmode variants. (STR_TO_BFP): Use strtold for XFmode or TFmode. (TFtype): Define if TFmode is supported. * doc/libgcc.texi (Decimal float library routines): Document TF conversion functions. gcc/testsuite/ * gcc.dg/dfp/convert-bfp.c: Replace SKIP_LONG_DOUBLE with runtime checks for size of long double. * gcc.dg/dfp/convert.h: New file. * gcc.dg/dfp/convert-bfp-2.c: New test. * gcc.dg/dfp/convert-bfp-3.c: Ditto. * gcc.dg/dfp/convert-bfp-4.c: Ditto. * gcc.dg/dfp/convert-bfp-5.c: Ditto. * gcc.dg/dfp/convert-bfp-6.c: Ditto. * gcc.dg/dfp/convert-bfp-7.c: Ditto. * gcc.dg/dfp/convert-bfp-8.c: Ditto. * gcc.dg/dfp/convert-bfp-9.c: Ditto. * gcc.dg/dfp/convert-bfp-10.c: Ditto. * gcc.dg/dfp/convert-bfp-11.c: Ditto. Added: trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-10.c trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-11.c trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-2.c trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-3.c trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-4.c trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-5.c trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-6.c trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-7.c trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-8.c trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-9.c trunk/gcc/testsuite/gcc.dg/dfp/convert.h Modified: trunk/gcc/ChangeLog trunk/gcc/config/dfp-bit.c trunk/gcc/config/dfp-bit.h trunk/gcc/doc/libgcc.texi trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp.c Fixed in what will be 4.3.0. |