uninit warnings (was Re: (Really, summarizing remaining warnings))
Jeffrey A Law
law@hurl.cygnus.com
Wed Mar 31 18:59:00 GMT 1999
In message < 199903112214.RAA06390@blastula.phys.columbia.edu >you write:
> void remove_dupes (struct list *el)
> {
> struct list *p, *q, *r;
>
> for (p = el; p; p = p->next)
> {
> for (q = el; q != p; q = q->next)
> if (q->id == p->id)
> {
> r->next = p->next;
> free (p);
> p = r;
> break;
> }
> r = p;
> }
> }
>
> r cannot be used uninitialized because the inner loop will not be
> executed on the first trip through the outer loop
> (p = el, q = el; therefore q == p).
Interesting. Not an easy case for the compiler to catch though. It *may*
be possible to find this via control dependence analysis (the first block
in the inner loop is control dependent on the conditional branch at the
end of the outer loop).
I know how to build a control dependence analyzer now, but I'm not sure
how to hook into the uninitialized warnings analysis or anything like
that yet.
jeff
More information about the Gcc-patches
mailing list