2 ms·
There are trivial cases of the use of an uninitialized variable that elementary data flow analysis will uncover. When the variable definition and its use are t
by kazinator 3y ago
There are trivial cases of the use of an uninitialized variable that elementary data flow analysis will uncover.
When the variable definition and its use are together in the same basic block, it's immediately obvious that the variable has a next-use on entry into the block, and that its definition hasn't supplied it with a value.
From there it gets complicated. GCC has a history of emitting overly zealous diagnostics in this area, warning about possibly uninitialized variables that can be proven not to be.
The difficulty is equivalent to the halting problem:
void f()
{
int x;
if (invokes_undefined_behavior(f))
x = 'A';
putchar(x);
}