https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82071
Bug ID: 82071
Summary: Error in assign-ops in combination with
FLT_EVAL_METHOD
Product: gcc
Version: 4.8.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: willemw at ace dot nl
Target Milestone: ---
Compiler:
Target: i686-linux-gnu
GNU C (Ubuntu 4.8.4-2ubuntu1~14.04.3) version 4.8.4 (i686-linux-gnu)
Compile option: -std=c99
The 4 expressions in the program below should give all the same answer.
When using the mentioned compiler that has FLT_EVAL_METHOD=2 gives
3 different answers.
The program:
# include <stdio.h>
# include <float.h>
int
main()
{
float f = 1.0;
double d = 1.0;
int i, j;
#ifdef FLT_EVAL_METHOD
printf("FLT_EVAL_METHOD: %d\n", FLT_EVAL_METHOD );
#endif
i = 0x10001234;
i += f;
printf("i += f; \t0x%x\n", i );
i = 0x10001234;
i += 1.0f;
printf("i += 1.0f;\t0x%x\n", i );
i = 0x10001234;
i = i + f;
printf("i = i + f;\t0x%x\n", i );
i = 0x10001234;
i = i + 1.0f;
printf("i = i + 1.0f;\t0x%x\n", i );
}
The results:
FLT_EVAL_METHOD: 2
i += f; 0x10001240
i += 1.0f; 0x10001235
i = i + f; 0x10001241
i = i + 1.0f; 0x10001241
The correct answers is 0x10001241: the expression should be evaluated in long
double.