possible bug with compiled code

H. James de St. Germain germain@cs.utah.edu
Fri Aug 10 12:18:00 GMT 2001


Hi there,

I'm using:

  % g++ -v
  Reading specs from /usr/local/gnu/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/specs
  gcc version 2.95.1 19990816 (release)

on:

  Linux juggler 2.2.19-smp #1 SMP Wed May 30 10:52:26 MDT 2001 i686 unknown

the problem:

  the != operator seems to be giving the wrong truth value during execution.
  In the code below, temp should be equal to the right hand expression.

here is the code:

  #include <stdio.h>
  #include <math.h>
  int
  main()
  {
    double temp;
    double val1, val2;
  
    val1 = 3.1413;
    val2 = .00006;
  
    temp = fabs(cos(val1) * cos(val2) + sin(val1) * sin(val2)); 
  
    if (temp != fabs(cos(val1) * cos(val2) + sin(val1) * sin(val2)))  
      {
        printf("%.100f != %.100f\n", temp,
	       fabs(cos(val1) * cos(val2) + sin(val1) * sin(val2)));
      }
  
    return 0;
  }
  

this is my first bug report so I hope I got everything you need.

cheers
  jim



More information about the Gcc-bugs mailing list