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

**URL:** https://discourse.itk.org/t/addressing-itkindex-h-391-27-warning-array-subscript-is-above-array-bound/785
**Category:** Engineering
**Tags:** dashboard, warnings
**Created:** [March 20, 2018, 7:30pm UTC](https://discourse.itk.org/t/addressing-itkindex-h-391-27-warning-array-subscript-is-above-array-bound/785 "2018-03-20T19:30:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [March 20, 2018, 7:30pm UTC](https://discourse.itk.org/t/addressing-itkindex-h-391-27-warning-array-subscript-is-above-array-bound/785/1 "2018-03-20T19:30:23Z")

</div>

On the [CircleCi builds](https://open.cdash.org/viewBuildError.php?type=1&buildid=5303426) we are getting large number of error like this:

```auto
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:

> <https://github.com/InsightSoftwareConsortium/ITK/blob/07e9edb9bc876404590b25982a5ff822f610380e/Modules/Core/Common/include/itkImageAlgorithm.hxx#L152>

  

> <https://github.com/InsightSoftwareConsortium/ITK/blob/07e9edb9bc876404590b25982a5ff822f610380e/Modules/Core/Common/include/itkImageAlgorithm.hxx#L163>

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`.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [March 21, 2018, 6:11pm UTC](https://discourse.itk.org/t/addressing-itkindex-h-391-27-warning-array-subscript-is-above-array-bound/785/2 "2018-03-21T18:11:39Z")

</div>

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

It seems to work:  
[https://github.com/InsightSoftwareConsortium/ITK/pull/43](https://github.com/InsightSoftwareConsortium/ITK/pull/43)
