The usual idea in cryptography is to zeroize temporary components.
The compiler will optimize away however if its just stack space :(
That's exactly the reason, compilers would maybe only care about it with -O0
FWIW, SecureZeroMemory exists to prevent that optimization.