[cfe-dev] Understand assumptions towards uninitialized variables on stack

Stephan Bergmann via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 21 08:58:12 PST 2018


On 21/11/2018 16:03, via cfe-dev wrote:
>> uninitialized variables on the stack is assumed to be zero due to
>> some reason,
> 
> That is not exactly what happened.  The assignment is from uninitialized
> memory, which will have an unknown value.  Because the value is unknown,
> the assignment can be optimized to avoid a read from memory, and
> substitute any convenient value, without perturbing any defined property
> of the program. The most convenient value to use here is zero.

But why bother to come up with a specific value at all, why not drop the 
"xorl %eax, %eax" completely and use whatever value is present in %eax?




More information about the cfe-dev mailing list