Bug 56404 - About fpclassify and standard C99
Summary: About fpclassify and standard C99
Status: RESOLVED MOVED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-20 00:06 UTC by argentinator.gcc.questions
Modified: 2013-02-20 00:21 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description argentinator.gcc.questions 2013-02-20 00:06:49 UTC
(First of all, I apologize because I don't know which is the right section to post this message).

I think that probably there is a bug with the macro fpclassify(). The following program classifies a 'double subnormal' number as a 'normal' one (maybe the value it is seen by the macro as a 'long double').

----------------------------------------------------------------
#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 x == %X\n\nclass z == %X\n", 
           x, fpclassify(x), fpclassify(z));
}
----------------------------------------------------------------

My compiler is GCC 4.7.2 on MinGW, under Windows 7.
The compiler option is just: -std=c99. (Anyway, without command line options I have found the same results).
I have FLT_EVAL_METHOD == 2.

The output I have obtained is:

--------------------------------------------------------------
x == 0x8p-1035

class x == 400

class z == 4400
--------------------------------------------------------------

Comments:

* x is a 'double subnormal' number.
* fpclassify(x) tells that x is a 'normal' value (0x400), and this would be wrong.
* fpclassify(z) tells that z is a 'long double subnormal' value (0x4400), which is right.

It seems that fpclassify(x) have not recognized that x has type 'double'.
Comment 1 Andrew Pinski 2013-02-20 00:13:48 UTC
Report this to the mingw folks since they are the ones who provide fpclassify.  That is they provide the header file which does fpclassify and GCC does not.
Comment 2 argentinator.gcc.questions 2013-02-20 00:21:56 UTC
(In reply to comment #1)
> Report this to the mingw folks since they are the ones who provide fpclassify. 
> That is they provide the header file which does fpclassify and GCC does not.

Sorry because my ignorance.

Thanks by your advice.