LoginSignup
0

More than 5 years have passed since last update.

Eigen内部の警告

Last updated at Posted at 2017-12-08

今まで線形代数周りの計算は自前で行っていたのですがEigenで行うようにしてみました
ところがビルドしてみると警告が3つ

comparing floating point with == or != is unsafe [-Wfloat-equal]

Eigen/src/Core/arch/CUDA/Half.h
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator == (const half& a, const half& b) {
  return float(a) == float(b);
}
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator != (const half& a, const half& b) {
  return float(a) != float(b);
}

Member 'x' was not initialized in this constructor

Eigen/src/Core/arch/CUDA/Half.h
struct __half {
  EIGEN_DEVICE_FUNC __half() {} //この行
  explicit EIGEN_DEVICE_FUNC __half(unsigned short raw) : x(raw) {}
  unsigned short x;
};

これは...
浮動小数点の等価比較をライブラリがしてしまうのか...(困惑)

警告を無視し続けるのは嫌ですし、かといって-Wfloat-equalを無効にしてしまうとfloatの等価比較を乱用する人が現れてくるし...

うまい方法はないものか...

環境

gcc6.2.1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0