on-internet
← Community

std::array at function not throwing out of range

Stack Overflow ·

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?

Comments

Sign in or sign up to comment and upvote.

No comments yet.