cppcoreguidelines-pro-bounds-constant-array-index.rst 1019 Bytes
Newer Older
1
2
.. title:: clang-tidy - cppcoreguidelines-pro-bounds-constant-array-index

3
4
5
6
cppcoreguidelines-pro-bounds-constant-array-index
=================================================

This check flags all array subscript expressions on static arrays and
7
8
``std::arrays`` that either do not have a constant integer expression index or
are out of bounds (for ``std::array``). For out-of-bounds checking of static
9
arrays, see the `-Warray-bounds` Clang diagnostic.
10
11

This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see
12
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-bounds-arrayindex.
13

14
15
Optionally, this check can generate fixes using ``gsl::at`` for indexing.

16
17
18
19
20
21
22
Options
-------

.. option:: GslHeader

   The check can generate fixes after this option has been set to the name of
   the include file that contains ``gsl::at()``, e.g. `"gsl/gsl.h"`.
23
24
25
26
27

.. option:: IncludeStyle

   A string specifying which include-style is used, `llvm` or `google`. Default
   is `llvm`.