<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJylU02PmzAQ_TVwGQWxBsJy4LDJdtVDpfawf8DAAG4cG_kjLP--Y0KatNpL1chybGbmzXsz40Z3S_3D6KTRXnU2yl7gsJ7A8h7dApPRvZBI18VCr6XUs1AD-UXpa5Te9uzLFpawAPFdyQWE6vCDdqeBGxPCvaVQaLWyjisH-DEZtFbQ_RHsG7qIlRak1ifgDtwoLPny8yQxYkeYRzQIM24JuLrCwyzcCPwzeIjY8xNoA2nEqgDReBf8OuHIyqVc_tazT6-rjdghrOtXlgnVSt8hRNlxTUrCH-Os6wJS9rIZj6Q-5GOhQNu3w2MA2amomvg1WsuVU6B49Sg3V6CfQefNpjQqDsGRSLzBE4R6p1HxekcuX_9S8Zjxq57xgiawOkquht276BbAs3CWijdzoz5v790CnQalHXUTt8pb39jWiMmF3ihq2K031LjgSS0ioTig-aw7RHzFGqzcikc1e6YyUJB1yEkoCZ6mVhscvOhQCoV2R4O5uw7t7ga6W-ns1tyhIg8SjtrLDhbtgaaIUzaHUga6RNYExjRSxJaY6mnSxnklaPhpdAdxIZlgz9w48rR-GNCGsYEQQy244r-PXJ1sEnd11lVZxWPu3ahNPfELypNZ_ElfYm9kPTo3hWcWsTdaA82sb5JWn-ki5eX2F9T9xJYK8Sas9WjpUGRVVcZjnbO-SfuiZ1WfZSXb5xkrWJs_F6zMeMHzWPIGpa2pahFjCmdYIehMNYn_n4GoWcrCoi1nTywpK7bvqmKfY9l3rEijPMUzFzIJOIk2Q2zqFbLxgyWjFNbZu5HTFAwKcSVMDJ1wEuv7cIaR--f2Q0utbPB333p6_X--zniVVa-afgHXpZ2F>53997</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang-Tidy: cppcoreguidelines-pro-bounds-constant-array-index can be smarter for std::array
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          pavelkryukov
      </td>
    </tr>
</table>

<pre>
    Pro.bounds: Bounds safety profile says following:

> Bounds.2: Only index into arrays using constant expressions

Let's look at this example, where we index an array with a constant expression (1 or 0), but conditionally:

```c++
#include <array>

std::array<int, 2> array;

int foo(bool cond)
{
    return array[cond ? 1 : 0];
}
```

However, Clang-Tidy emits a warning:

> warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]

Could you please tell whether there is an opportunity to give a smarter suggestion here?
Thanks.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVU02TmzAM_TVw0YQhJizhwGGT7U4PnWkP-wcMVsCNYzP-SJZ_X5mQJt3JpYzH2Eh6enoSrRFT88uarDVBC5cUr7CbT-D4Af0EozUHqZCuk4ODUcpcpO7JL8nfkvy2F9-WsIxFiJ9aTSC1wE_avQFubQwPjkKhM9p5rj3g52jROUn3R7Af6BNWOVDGHIF78IN05MtPo8KE7eEyoEW44JKA6ys8XKQfgD-Dh4Rt12As5AmrI0QbfPQT0pOVKzV9reclv64uYbu4rl9ZIXWngkBIiv2clAp_jHNeRKTidTHuqfqYj0WBlm-7xwCyk6iG-LXGqJlTpHj1qBZXoMeiD3apNCl30ZFIvMMaot55Ur7dkau3L1U8ZvxuLnhGG1ntFdf96kOKCfAkvSPxLtzq5-29W0AY0MZTN3FR3oXWdVaOPvZGU8NuvaHGRU9qERWKPdpn3SHiM1bv1CIeabYlGSjIeeRUKBU8jp2x2AcpUEmNbkWDuboO7eoGuprprObcUZGHEvYmKAGTCUBTxCmbR6UiXSJrI2MaKWJLTM04GuuDljT8NLq9PFOZ4E7cevJ0oe_RxbGBGEMtuOJ_DFwfXZaKphB1UfPUS6-wuUschfvvIqAjQi3-zX6gGf53xtJgVTN4P8ZfN2HvtHr6D0KbdeZEF6XOt1dM9hs7EvddOhfQ0aEs6rpKh0ZsS8F5jmW3Ldb5pmUlbrCoinVdi3XOqlTxFpVrqBMJYxovMEPQmXROZcNyFhdtG7ZmWVWzF1GXLxusDoKVebLJ8cSlyiKPzNg-tc1MqQ29I6OSzru7kdNc9BpxTkf4PPjB2GbkZ1RHO4WjOadz_mbm_wdQqYhe">