This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1520 - Request to fix compiler warnings of comparing floats
Summary: Request to fix compiler warnings of comparing floats
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.5 (future version)
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-14 01:41 UTC by csukuangfj
Modified: 2019-12-04 17:29 UTC (History)
3 users (show)



Attachments

Description csukuangfj 2018-02-14 01:41:27 UTC
While compiling the Eigen library provided by Open3D (https://github.com/IntelVCL/Open3D), I got the following
compiler warnings


xx/Open3d/src/External/Eigen/Eigen/src/Core/arch/CUDA/Half.h:241:19: warning: 
      comparing floating point with == or != is unsafe [-Wfloat-equal]
  return float(a) == float(b);
         ~~~~~~~~ ^  ~~~~~~~~
xx/Open3d/src/External/Eigen/Eigen/src/Core/arch/CUDA/Half.h:244:19: warning: 
      comparing floating point with == or != is unsafe [-Wfloat-equal]
  return float(a) != float(b);
         ~~~~~~~~ ^  ~~~~~~~~
2 warnings generated.


The problem exists also for the current master branch of Eigen.

See the issue on GitHub: https://github.com/IntelVCL/Open3D/issues/154
Comment 1 Christoph Hertzberg 2018-02-14 10:52:16 UTC
At that point making an (un-)equal comparison is the only meaningful thing to do. We could globally or locally disable the warning.
If we want to disable it locally, we should probably factor out the equal comparison to some method, so we don't add to much #pragma noise into the code.
Comment 2 Christoph Hertzberg 2018-02-14 10:55:45 UTC
There are some other points (mostly fall-back implementations), where we do equal-comparisons to Scalar(1) or Scalar(0), which in fact also generate said warning. (If you compile in C++03 mode with -Wfloat-equal using g++)
Comment 3 Gael Guennebaud 2018-04-11 13:40:07 UTC
Actually we might want that a warning is still generated if operator==(half,half) is really called, but I cannot see how to do this: I tried to delay the instantiation of operator== by making it template, but because of the explicit conversions to float, the code after the conversions to float is checked whatsoever.

https://bitbucket.org/eigen/eigen/commits/b797fa480f14
Comment 4 Nobody 2019-12-04 17:29:06 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1520.

Note You need to log in before you can comment on or make changes to this bug.