The code

inline int almost_equal(float a, float b, int maxUlps = 16) {
  int intDiff = *(reinterpret_cast<int*>(&a)) -
                    *(reinterpret_cast<int*>(&b));
  printf("intDiff %d\n",intDiff);
  return intDiff;
}

gives different results when compiled with and without -O2
(yes, floats are involved, but it has nothing to do with rounding)


-- 
           Summary: wrong result after reinterpret_cast from float* to int*
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ulrich dot lauther at siemens dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to