Addressing "itkIndex.h:391:27: warning: array subscript is above array bound"

On the CircleCi builds we are getting large number of error like this:

In file included from /ITK/Modules/Core/Common/include/itkContinuousIndex.h:22:0,                            |  constexpr size_type size() const
                 from /ITK/Modules/Core/Common/include/itkImageRegion.h:34,                                  |  {
                 from /ITK/Modules/Core/Common/include/itkImageIORegion.h:24,                                |    return VDimension;
                 from /ITK/Modules/IO/ImageBase/include/itkImageIOBase.h:26,                                 |  }
                 from /ITK/Modules/IO/IPL/include/itkIPLCommonImageIO.h:36,                                  |
                 from /ITK/Modules/IO/GE/include/itkGEAdwImageIO.h:37,                                       |  constexpr size_type max_size() const
                 from /ITK/Modules/IO/GE/test/itkGEImageIOTest.cxx:19:                                       |  {
/ITK/Modules/Core/Common/include/itkIndex.h: In member function 'void itk::ImageFileWriter<TInputImage>::Gen\|    return VDimension;
erateData() [with TInputImage = itk::Image<short int, 3u>]':                                                 |  }
/ITK/Modules/Core/Common/include/itkIndex.h:391:27: warning: array subscript is above array bounds [-Warray-\|
bounds]                                                                                                      |  constexpr bool empty() const
     return m_InternalArray[pos];                                                                            |  {
                           ^         

I was unable to reproduce this with RH devtools-3 with GCC 4.9.2. However, I was able to reproduce the error message on a debian:jessie docker image with the default g++ 4.9.2 compiler installed.

The error is coming from these two lines:


I don’t believe this is a real problem. Adding an ITK_GCC_PRAGMA_DIAG(ignored "-Warray-bounds") around the code in the ImageAlgorithm::DispatchedCopy method had not effect as the the warning is coming from itk::Index.

I have a proposed patch here which just suppresses it on CircleCI:
http://review.source.kitware.com/#/c/23284/1

It seems to work:
https://github.com/InsightSoftwareConsortium/ITK/pull/43