[Bug c/50773] float values are printed with greater precision than the float data type has when given as an argument to printf()
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Tue Oct 18 14:50:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50773
--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-10-18 14:49:28 UTC ---
On Tue, 18 Oct 2011, rguenth at gcc dot gnu.org wrote:
> Needs -fexcess-precision=standard -m32 to trigger. libcpp does the
> parsing of FP constants IIRC, and the C++ frontend does not implement
> -fexcess-precision.
>
> CCing Joseph.
>
> Testcase that fails with -fexcess-precision=standard -m32:
>
> extern void abort (void);
> int
> main()
> {
> float a = 268517138.f;
> if (a != 268517138.f)
> abort ();
> return 0;
> }
I don't see any bug there. With -fexcess-precision=standard,
FLT_EVAL_METHOD is 2, "evaluate all operations and constants to the range
and precision of the long double type". Thus 268517138.f has type float
but a value represented to the precision of long double - and the
conversion to the precision of float takes place for the initialization
but not for the comparison. (Without -fexcess-precision=standard -
outside any conformance mode - FLT_EVAL_METHOD is still 2, but exactly
what happens is unpredictable.)
More information about the Gcc-bugs
mailing list