4 ms·
"So for the compiler to be able to statically compute the result it would need to know that the std::vector stuff doesn't have side effects. " It can know this
by DannyBee 11y ago
"So for the compiler to be able to statically compute the result it would need to know that the std::vector stuff doesn't have side effects.
"
It can know this the same way it knows about memcpy.
Most of them have library call info for things that have standardized guarantees.
Even if it didn't, it knows what malloc does, it knows this variable never escapes, and ...