Skip to content

COMP: Fix some compiler warnings

Laurențiu Nicola requested to merge fix-warnings into develop

I know that OSSIM is going away, but they made a mess of the compilation output and it was hard to see the others.

I still get a couple of warnings about GetGeoTransform accessing out-of-bound values when defined on one-dimensional otbImages. This is coming from ROIdataConversion, and I'm not sure there's much we can do about it.

In file included from /home/me/Projects/otb/Modules/Core/ImageBase/include/otbImage.h:259,
                 from /home/me/Projects/otb/Modules/Filtering/ChangeDetection/test/otbKullbackLeiblerSupervizedDistanceImageFilter.cxx:22:
/home/me/Projects/otb/Modules/Core/ImageBase/include/otbImage.hxx: In member function ‘otb::Image<TPixel, VImageDimension>::VectorType otb::Image<TPixel, VImageDimension>::GetGeoTransform() const [with TPixel = double; unsigned int VImageDimension = 1]’:
/home/me/Projects/otb/Modules/Core/ImageBase/include/otbImage.hxx:147:31: warning: array subscript 1 is outside array bounds of ‘itk::Point<double, 1> [1]’ [-Warray-bounds]
  147 |   geoTransform[3] = origin[1] - 0.5 * spacing[1] * direction[1][1];
      |                     ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/me/Projects/otb/Modules/Core/ImageBase/include/otbImage.hxx:141:8: note: while referencing ‘origin’
  141 |   auto origin = this->GetOrigin();
      |        ^~~~~~
/home/me/Projects/otb/Modules/Core/ImageBase/include/otbImage.hxx:147:37: warning: array subscript 1 is outside array bounds of ‘itk::Vector<double, 1> [1]’ [-Warray-bounds]
  147 |   geoTransform[3] = origin[1] - 0.5 * spacing[1] * direction[1][1];
      |                                 ~~~~^~~~~~~~~~
/home/me/Projects/otb/Modules/Core/ImageBase/include/otbImage.hxx:142:8: note: while referencing ‘spacing’
  142 |   auto spacing = this->GetSpacing();
      |        ^~~~~~~
/home/me/Projects/otb/Modules/Core/ImageBase/include/otbImage.hxx:147:64: warning: array subscript 2 is outside array bounds of ‘itk::Matrix<double, 1, 1> [1]’ [-Warray-bounds]
  147 |   geoTransform[3] = origin[1] - 0.5 * spacing[1] * direction[1][1];
      |                                                    ~~~~~~~~~~~~^
/home/me/Projects/otb/Modules/Core/ImageBase/include/otbImage.hxx:143:8: note: while referencing ‘direction’
  143 |   auto direction = this->GetDirection();
      |        ^~~~~~~~~

Merge request reports

Loading