This is the mail archive of the gcc@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: better -Wuninitialized (Re: Ada files now checked in)


<<1       int a, b;
2
3       b = foo();
4       if (b < 100)
5         a = 10;
6       bar();
7       if (b < 100)
8         b = b + a;

which is the canonical case that the current code gets wrong.  (And
imagine that line 7 is actually several hundred lines of spaghetti
which do not touch A or B.)
>>

I am not sure I would say that current code gets this "wrong". Sure you
can imagine building this particular theorem into the code, but you will
always have cases involving arbitrarily complex theorems. I do agree
it would be desirable to go just far enough to catch this case, i.e.
recognize absolutely identical conditions with invariant operands, but
even this is much trickier than people might imagine.

<<> > It would often be helpful if an uninitialized variable could be
> > automatically set to a "poison" value by the compiler.  This would
>>

In Ada, there is Normalize_Scalars which has this kind of effect, and
it has been extended in GNAT with the addition of Initialize_Scalars,
which allows the value set to be specified at bind time. So you can
see if your code depends on the value used.


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