2 ms·
Doesn't the std::vector calls mess things up? Now the compiler has to track those as well, they involve the allocator which calls into the OS. So for the compi
by 21 11y ago
Doesn't the std::vector calls mess things up? Now the compiler has to track those as well, they involve the allocator which calls into the OS.
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.
Of course, the compiler could have special knowledge of std::vector, like for example in general it has about memcpy.
- 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 ...