https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79950
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- The two cases are not equivalent, because the bounds of a[10] are known at compile-time, but v.size() is not. The only way to know v.size() is with a run-time check, which has a non-zero cost.