std::array at function not throwing out of range [closed]

1 day ago 1
ARTICLE AD BOX

While debugging something I stumbled into this behavior on godbolt. When compiling and running the following (godbolt link https://godbolt.org/z/9c5966sbK):

#include <array> int main() { std::array<int, 4> arr{1,2,3,4}; int val = arr.at(5); return val; }

using latest x86 versions of gcc, clang and msvc, with optimizations disabled (-O0 and /Od resp.) msvc doesn't throw std::out_of_range exception.

Why does this happen?

Read Entire Article