[ovs-dev] "array subscript is above array bounds" for flowmap_set(), flowmap_clear()
Jarno Rajahalme
jrajahalme at nicira.com
Thu Aug 27 00:14:10 UTC 2015
> On Aug 26, 2015, at 4:50 PM, Ben Pfaff <blp at nicira.com> wrote:
>
> GCC 4.9 doesn't like flowmap_clear() and flowmap_set(). Maybe that's
> why you had those seemingly redundant tests in there? I'm taking a
> closer look to see whether I believe its claims though.
>
> CC lib/classifier.lo
> In file included from ../lib/match.h:20:0,
> from ../lib/classifier.h:302,
> from ../lib/classifier.c:18:
> ../lib/classifier.c: In function 'miniflow_get_map_in_range':
> ../lib/flow.h:520:28: error: array subscript is above array bounds [-Werror=array-bounds]
> fm->bits[unit + 1] &= ~(n_bits_mask >> (MAP_T_BITS - idx));
> ^
> ../lib/flow.h:520:28: error: array subscript is above array bounds [-Werror=array-bounds]
> cc1: all warnings being treated as errors
> Makefile:3910: recipe for target 'lib/classifier.lo' failed
> make[2]: *** [lib/classifier.lo] Error 1
> CC lib/flow.lo
> In file included from ../lib/flow.c:18:0:
> ../lib/flow.c: In function 'miniflow_extract':
> ../lib/flow.h:502:28: error: array subscript is above array bounds [-Werror=array-bounds]
> fm->bits[unit + 1] |= n_bits_mask >> (MAP_T_BITS - idx);
> ^
> ../lib/flow.h:502:28: error: array subscript is above array bounds [-Werror=array-bounds]
> cc1: all warnings being treated as errors
This rings a bell, and today I was compiling with clang only, so I did not see them.
Maybe we introduce the tests back with a comment stating the reason we have them. They will be removed by the compiler anyway, as both relevant arguments (‘idx’ and ’n_bits’) are compile-time constants.
Jarno
More information about the dev
mailing list