Jeffrey A Law wrote:- > After pondering this some more I almost wonder if what we need is a > separate warning for variables which were potentially uninitialized > but which optimization passes somehow proved were unused or the paths > in which the variable was uninitialized were unexecutable. > > So the early pass would catch unconditionally uninitialized variables; > it would also record (but not warn for) maybe uninitialized variables > (by detecting default definitions appearing in PHI nodes). > > The late pass would then issue a may-be-uninitialized warning for > any variables which still had a default definition appearing in a > PHI node.
I think this is a better approach than the current one, and that if we go down this patch then we should grasp the opportunity to do it right - the early pass should be in the front end. Let the optimizers do the fancy cases. 90% of cases that catch bugs can be handled in the front end I expect, with a very simple algorithm. Neil.