Bug 56397 - Floating Point constant diagnotic in C and x87 and -fexcess-precision=standard
Summary: Floating Point constant diagnotic in C and x87 and -fexcess-precision=standard
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2013-02-19 14:36 UTC by argentinator.gcc.questions
Modified: 2021-09-30 01:44 UTC (History)
0 users

See Also:
Host:
Target: i?86 x86_64-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-09-29 00:00:00


Attachments
Source code, ".i" file, and compiler output in a ".txt" file. (1.31 KB, application/octet-stream)
2013-02-19 14:36 UTC, argentinator.gcc.questions
Details

Note You need to log in before you can comment on or make changes to this bug.
Description argentinator.gcc.questions 2013-02-19 14:36:43 UTC
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;
}
Comment 1 Jonathan Wakely 2013-02-19 15:12:56 UTC
I get the expected result with 4.7.2 on MinGW and with all versions on GNU/Linux
Comment 2 argentinator.gcc.questions 2013-02-19 16:56:52 UTC
(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).
Comment 3 Jonathan Wakely 2013-02-19 17:10:10 UTC
(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.
Comment 4 jsm-csl@polyomino.org.uk 2013-02-19 17:10:46 UTC
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).
Comment 5 argentinator.gcc.questions 2013-02-19 18:58:17 UTC
(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 */
------------------------
Comment 6 jsm-csl@polyomino.org.uk 2013-02-19 21:51:56 UTC
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.
Comment 7 argentinator.gcc.questions 2013-02-19 22:01:16 UTC
(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 :(
Comment 8 Richard Biener 2013-02-20 09:33:37 UTC
Confirmed as a diagnostic issue.