Created attachment 29496 [details] Source code, ".i" file, and compiler output in a ".txt" file. I think that the compiler doesn't recognize properly the type of the floating-point constants for the standard C99. A straight example is the simple sentence: (1.1F & 1); In this case, 1.1F should be considered as a 'float' constant, but the compiler triggers this error message: error: invalid operands to binary & (have 'long double' and 'int') Thus, the compiler considers that 1.1F has type 'long double', but 'float' is expected. I am running GCC 4.6.1 with MinGW, under a Windows 7 system. In my system, FLT_EVAL_METHOD == 2, but I think that this is not the problem, and that we have actually some kind of compiler bug. The source code is just this: --------------------------------------------------- int main(void) { 1.1F & 1; }
I get the expected result with 4.7.2 on MinGW and with all versions on GNU/Linux
(In reply to comment #1) > I get the expected result with 4.7.2 on MinGW and with all versions on > GNU/Linux I have reinstalled MinGW in my computer, under Windows 7. Now I have GCC 4.7.2, and I still get the non-expected result, that is, I obtain again the same error message that considers 1.1F as a 'long double' constant. (The compiler option is always -std=c99).
(In reply to comment #2) > (The compiler option is always -std=c99). Ah sorry, although I used -std=c99 on GNU/Linux, I didn't on MinGW, and can confirm it says 'long double' with 4.7.2 on MinGW, so it looks like a target issue.
This looks like it's just an issue with the diagnostic text (binary_op_error being called with the type in which the floating-point operand is being represented, rather than with its semantic type).
(In reply to comment #4) > This looks like it's just an issue with the diagnostic text > (binary_op_error being called with the type in which the floating-point > operand is being represented, rather than with its semantic type). Is this "type/semantic type" issue related to the following observation? I tried to print the value of fpclassify for a 'subnormal' value whose type is 'float' or 'double', but it seems the compiler considers everything as a 'long double'. The source code would be: ------------------------------------------------------------------------------ #include <math.h> #include <float.h> #include <stdio.h> int main(void) { double x = DBL_MIN / 1024.0; long double z = LDBL_MIN / 1024.0; printf("x == %a\n\nClass of x == %X\n\nClass of z == %X\n", x, fpclassify(x), fpclassify(z)); } ------------------------------------------------------------------------------ (As always, I am running on Windows 7, MinGW, GCC 4.7.2, command line option -std=c99, and I have FLT_EVAL_METHOD == 2). My output is: ------------------------ x == 0x8p-1035 /* This is a 'double subnormal' value */ Class of x == 400 /* x is 'double' and normal, so this seems wrong */ Class of z == 4400 /* z is 'long double' and 'subnormal': OK */ ------------------------
On Tue, 19 Feb 2013, argentinator.gcc.questions at outlook dot com wrote: > I tried to print the value of fpclassify for a 'subnormal' value whose type is > 'float' or 'double', but it seems the compiler considers everything as a 'long > double'. The source code would be: fpclassify is a matter for your C library, not for GCC, so report such issues there.
(In reply to comment #6) > On Tue, 19 Feb 2013, argentinator.gcc.questions at outlook dot com wrote: > > > I tried to print the value of fpclassify for a 'subnormal' value whose type is > > 'float' or 'double', but it seems the compiler considers everything as a 'long > > double'. The source code would be: > > fpclassify is a matter for your C library, not for GCC, so report such > issues there. Sorry :(
Confirmed as a diagnostic issue.