Suggestion for array bounds warning

If I write
  int arr[2];
  arr[2] = -1;

I get "warning: array index 2 is past end of array".
That's great.

but if I write:
  std::array<int, 2> arr;
  arr[2] = -1;

I get no warning.
I think that "it would be nice" if clang warned in that case also.

-- Marshall

Marshall Clow Idio Software <mailto:mclow.lists@gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki

FWIW, I just committed a change to libc++ so that:
  std::array<int, 2> arr;
  std::get<2>(arr) = -1;

will static_assert.
Thanks to Howard for the code review.

-- Marshall

Marshall Clow Idio Software <mailto:mclow.lists@gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki