Skip to content

Implicit conversion loss warning

Summary

Warning 1

Compiler warns about implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] in file Eigen/src/Core/products/GeneralBlockPanelKernel.h line 2357

psize = pack = left & ~1;

psize and pack are of type int, whereas left is of type Index.

I suggest to replace the above line by

psize = pack = (int)(left & ~1);

or change the type of psize and pack to Index, too.

Warning 2

Compiler warns about implicit conversion loses integer precision: 'Eigen::Index' (aka 'long') to 'int' [-Wshorten-64-to-32] in file Eigen/src/Core/Reverse.h line 194

.swap(xpr.rightCols(fix<HalfAtCompileTime>(half)).rowwise().reverse());

and line 193

xpr.leftCols(fix<HalfAtCompileTime>(half))

and line 181

.swap(xpr.bottomRows(fix<HalfAtCompileTime>(half)).colwise().reverse());

and line 180

xpr.topRows(fix<HalfAtCompileTime>(half))

Environment

  • Operating System : macOS
  • Architecture : Arm64
  • Eigen Version : 3.4.x (recent git checkout)
  • Compiler Version : AppleClang 13.0.0 (clang-1300.0.29.30)

Steps to reproduce

Get latest git checkout and run

mkdir build && cd build && cmake .. && make mixingtypes_6 array_reverse_1 array_reverse_2

Warning 1 is triggered by mixingtypes_6, warning 2 is triggered by array_reverse_1 and array_reverse_2 (actually all array_reverse_x tests).

Warning 1 is also raised by the Intel ICC compiler running on the following environment

  • Operating System : CentOS 8
  • Architecture : x86_64
  • Eigen Version : 3.4.x (recent git checkout)
  • Compiler Version : icc version 2021.5.0 (gcc version 8.5.0 compatibility)
Edited by Matthias Möller