This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: uninit warnings (was Re: (Really, summarizing remaining warnings))



  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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]