Your assumption is wrong for most platforms and environments. Data values can be kept in some registers or stack cells even if they aren't anymore from those ones. It's fully compiler's responsibility to put proper values in registers and cells according to the used calling convention and to comply with the required functionality, but nothing more is guaranteed. That's why e.g. local variables are filled with garbage on function entry: they keep some previous values, not cleared after some work finished.
Some tasks require data cleaning (e.g. deleting password contents after its applying) but this is done using explicitly coded cleaning of memory regions.
If you are thinking on languages with garbage collecting, that's another but similar story.