This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Problem with math functions (and -O2)


The following program works without optimization but not with:

#include <math.h>
#include <errno.h>
#include <string.h>

main() {
  double ii = 0.0, jj = 0.0;
  errno = 0;
  while( errno == 0 ) {

    ii = cosh( jj );
    printf( "cosh(%+9.4f)=%15g errno=%d %s \n",
      jj, ii, errno, strerror(errno));
    jj = jj + 1.0;
  }
}

What is the problem ?
errno remains 0 even when ii becomes infinity. This happens only with
optimization.

Thanks in advance.
Regards,
    Thomas

--
Thomas Hiller
COMPAQ Computer EMEA BV
SAP International Competence Center
LinuxLab




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]