Document: WG14 N1468
Submitter: Fred J. Tydeman (USA)
Submission Date: 2010-05-10
Related documents: N1435
Subject: Assumed types in F.9.2
Consider the following code based upon the first transformation in F.9.2:
#include <stdio.h> #include <float.h> int main (void){ float x = FLT_MIN * FLT_EPSILON; /* smallest subnormal number */ if( x / 2 != x * 0.5 ){ printf ("Bad transformation\n"); return 1; } return 0; }
Since x is of type float, x/2 is done as float and yields zero (if FLT_EVAL_METHOD is 0), while x*0.5 is done as double and yields one half of the smallest float subnormal (which is not zero as a double).
It appears that we need some words explaining that these transformations are type independent and shown as examples.
Add a paragraph to F.9.2 Expression transformations
While the following code shows (and assumes) double type, the same issues apply to all floating types.
Change existing F.9.2 integer constants (0, 1, 2) to double constants (0.0, 1.0, 2.0).