&quot;So for the compiler to be able to statically compute the result it would need to know that the std::vector stuff doesn&#x27;t have side effects.
&quot;<p>It can know this the same way it knows about memcpy.<p>Most of them have library call info for things that have standardized guarantees.<p>Even if it didn&#x27;t, it knows what malloc does, it knows this variable never escapes, and ...