This is the mail archive of the 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: Regression going from egcs-1.03 to egcs-19980803

  In message <>you write:
  > Hi there,
  > there appears to be a regression going from egcs-1.03 to the latest
  > snapshot (egcs-19980803).
  > The problem is reproducible by means of a few lines of C (or C++:
  > it doesn't matter).
  > Everything is provided and explained below.
  > Keep up the good work

  > The program (admittedly dumb -- a much reduced version of a perfectly
  > reasonable function in real code):
  > #include <assert.h>
  > int foo(int x)
  > {
  >   // Removing this assertion eliminates the warning.
  >   assert(x >= 0);
  >   // The '= 5' was added later to answer the question:
  >   // "could it be so broken to give the warning also for a variable
  >   // that is explicitely initialized?"
  >   // The answer is: yes.
  >   int i = 5;
  >   // Replacing x+3 by, e.g., x eliminates the warning.
  >   for (i = 0; i < x+3; ++i)
  >     // Replacing i > 3 by, e.g., i == 3 eliminates the warning.
  >     if (i > 3)
  >       return i;
  >   return -1;
  > }
  > ---------------------------------------------------------------------------
  > ----
  > The result with egcs-19980803:
  > $ /u/local/bin/gcc -save-temps -O2 -Wall -c
  > In function `int foo(int)':
  > warning: `int i' might be used uninitialized in this function
The code to detect potentially uninitialized variables is not very
good -- it reports many false positives.

-O2 optimization enables global cse, which happens to rearrange code
in a manner which triggers the false positive warnings.

This is not something we're likely to fix for egcs-1.1.  It would be
nice if someone could improve the uninitialized warning detection code
for a future release though.


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