public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Ada files now checked in
@ 2001-10-06 18:25 dewar
  2001-10-07  0:38 ` Diego Novillo
  0 siblings, 1 reply; 17+ messages in thread
From: dewar @ 2001-10-06 18:25 UTC (permalink / raw)
  To: dewar, dnovillo; +Cc: bosch, gcc, kenner, zack

<<$ gcc -Wuninitialized -ftree-ssa foo.c -O -c
foo.c: In function `main':
foo.c:3: warning: `b' is used uninitialized in this function
>>

Right, I know about those messages, the trouble is that the message
does not point to the problem point, it points instead to the declaration
of b. What you need in more complex cases is a pointer to the exact
occurrence that is detected as potentially troublesome

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: better -Wuninitialized (Re: Ada files now checked in)
@ 2001-10-07 15:19 dewar
  0 siblings, 0 replies; 17+ messages in thread
From: dewar @ 2001-10-07 15:19 UTC (permalink / raw)
  To: dnovillo, zack; +Cc: gcc

<<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.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2001-10-14  7:53 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-06 18:25 Ada files now checked in dewar
2001-10-07  0:38 ` Diego Novillo
2001-10-07  0:59   ` Zack Weinberg
2001-10-07 10:24     ` Diego Novillo
2001-10-07 10:53       ` better -Wuninitialized (Re: Ada files now checked in) Zack Weinberg
2001-10-07 10:57         ` Joseph S. Myers
2001-10-07 11:23           ` Diego Novillo
2001-10-07 11:21         ` Diego Novillo
2001-10-07 11:55           ` Zack Weinberg
2001-10-07 12:06             ` Daniel Berlin
2001-10-07 16:01             ` Diego Novillo
2001-10-07 11:29         ` Daniel Berlin
2001-10-07 11:05       ` Ada files now checked in Daniel Berlin
2001-10-07 11:29         ` Diego Novillo
2001-10-07 11:37           ` Daniel Berlin
2001-10-14  7:53       ` Joern Rennecke
2001-10-07 15:19 better -Wuninitialized (Re: Ada files now checked in) dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).