http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55560



             Bug #: 55560

           Summary: fesetround(FE_DOWNWARD) causes cos() to return values

                    outside the range of -1 to +1

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: major

          Priority: P3

         Component: other

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: p...@ecstaticlyrics.com





Created attachment 28852

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28852

Contents of /proc/cpuinfo



Simple test program:



#include <stdio.h>

#include <math.h>

#include <fenv.h>



void main() {

  double a, c;

  fesetround(FE_DOWNWARD);

  for (a = -M_PI; a <= +M_PI; a += 0.000001) {

    c = cos(a);

    if (c < -1.0 || c > +1.0) {

      printf("cos(%f) is not %f\n", a, c);

    };

  };

};



Compile like so: gcc -o test test.c -lm



Expected output is nothing at all, since cos() always returns values between

-1.0 and +1.0.  The actual output, however, is 20,009 lines.  Here are the

first ten:



cos(-3.141593) is not -1.000485

cos(2.430171) is not 3614403565883090812337301068370710204239577088.000000

cos(2.430172) is not 195176399637579483727029815821181674649563430912.000000

cos(2.430173) is not 386738395709080693943503989636585388708949131264.000000

cos(2.430174) is not 578300391780195078044017318793663580791807934464.000000

cos(2.430175) is not 769862387850731413470826575343659276213015281664.000000

cos(2.430176) is not 961424383920497666369804385270998542397395173376.000000

cos(2.430177) is not 1152986379989302370794292276806879317292807618560.000000

cos(2.430178) is not 1344548376056954223056908607395862930425122914304.000000

cos(2.430179) is not 1536110372123261919470271734482510711320211357696.000000



The problem disappears if the test program is compiled with "-m32" or if

"fesetround(FE_DOWNWARD)" is removed.

Reply via email to