News for hackers. Stuff that matters.
Re:GCC optimized code gives strange floating point results by leni536 on Monday February 27, 2017 @04:10AM (#13742924)
> But C Standard mandates IEEE 754 , too!

Are you sure? I can't find it in the standard, specifically not in [1] page 28., section 5.2.4.2.2.

[1] (the final draft of C1X, dated 12 April 2011) http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

Re:GCC optimized code gives strange floating point results by nortiero on Monday February 27, 2017 @05:20AM (#13743193)
You are absolutely correct, "mandates" is too strong a word. Annex F, which is normative, have a way out by not setting __STDC_IEC_559__, GCC6.3.0 does set a slightly different GCC_IEC_559. Yet I think that my argument still holds:

floating point calculations can be executed at wider range (§5.1.2.3.12);

assignments and casts are under obligation to wipe out that extra precision (§ same paragraph);

I am no language lawyer, but .. given the issue of program observable effects (§5.1.2.3.12) and the "as is" implied rule that governs optimizations, how possibly could equality be stable over time?

Re:GCC optimized code gives strange floating point results by leni536 on Monday February 27, 2017 @06:04AM (#13743368)
Yeah, you are right. It seems to be that the problem is that we cram two standards into too few types. Additionally to float, double, and long double there could be optional iec559_single_t, iec559_double_t and iec559_extended_t (similarly to stdint.h integer types). The operations on variables of these types could be strictly iec559 conformant.