This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: better -Wuninitialized (Re: Ada files now checked in)
- To: dnovillo at redhat dot com, zack at codesourcery dot com
- Subject: Re: better -Wuninitialized (Re: Ada files now checked in)
- From: dewar at gnat dot com
- Date: Sun, 7 Oct 2001 18:19:23 -0400 (EDT)
- Cc: gcc at gcc dot gnu dot org
<<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.