From: Zack Weinberg <zack@rabi.columbia.edu>
To: craig@jcb-sc.com
Cc: egcs@egcs.cygnus.com
Subject: Re: Uninitialized variable warnings
Date: Wed, 31 Mar 1999 23:46:00 -0000 [thread overview]
Message-ID: <199903160403.XAA28775@blastula.phys.columbia.edu> (raw)
Message-ID: <19990331234600.y-s40Jv5vpDhHmzFB5t9GVOCh-4v9EKtM5zNmQ6Afr0@z> (raw)
In-Reply-To: <19990315211232.23607.qmail@deer>
>>>>There are a number of other places where gcc has gotten it wrong, and
>>>>a few places where the warning indicates a real bug. There's also one
>>>>worrisome case, where we get it right or not unpredictably:
[...]
>>>Could you be more precise about "unpredictably"?
[...]
>>I mean that given two similar chunks of code one will get a warning
>>and the other won't, and the significant difference may seem to be
>>absolutely irrelevant as far as a human is concerned. A good example
>>is the `plist' variable in objc-act.c:generate_protocol_list. We warn
>>on that. Prune everything else out of the function, and the compiler
>>doesn't warn anymore.
>
>Hmm, so it's possible there's an uninitialized-variable bug in the
>compiler,
Unless we have false _negatives_ in -Wuninitialized, there don't seem
to be any problems with the section of the code (flow - I think) that
generates the warnings.
>but it might just be that the uninitialized-variable analysis
>(including all RTL transforms that precede it) is overly sensitive
>to things that would normally be thought of as irrelevant to the
>issue of whether a particular variable is initialized.
I believe it is CSE which is too sensitive. Here is a real example.
/* x86, 2.93.12 19990314
-O -Wall: warning
-O2 -Wall: warning
-O -Wall -DCASE2: no warning
-O -Wall -DCASE3: warning
-O2 -Wall -DCASE3: no warning */
struct operation {
short op;
char rprio;
#ifndef CASE2
char flags;
#endif
char unsignedp;
long value;
};
extern struct operation cpp_lex (void);
void
cpp_parse_expr (void)
{
int rprio;
struct operation op;
for (;;)
{
op = cpp_lex ();
switch (op.op)
{
case 0:
break;
#ifndef CASE3
case 1:
return;
#endif
case 2:
rprio = 1;
break;
default:
return;
}
if (op.op == 0)
return;
if (rprio != 1)
abort();
}
}
This is too complicated for flow to get the uninit warnings right no
matter which case it is. However, CSE is able to collapse CASE2 down to
for (;;)
{
op = cpp_lex ();
if (op.op != 2)
break;
}
which flow understands. It can do the same with CASE3, but only if -O2.
Now, the only significant differences in -dj dumps for default and
CASE2 are that CASE2 has (subreg:HI (reg:DI N)) in a few places where
default has (reg:HI N), and the single insn that initializes reg N is
different in mode and offset. I don't think there's a good reason for
cse to get this wrong.
zw
next prev parent reply other threads:[~1999-03-31 23:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-14 20:42 Zack Weinberg
[not found] ` < 199903150442.XAA28837@blastula.phys.columbia.edu >
1999-03-15 2:45 ` craig
[not found] ` < 19990315103933.22049.qmail@deer >
1999-03-15 4:56 ` Zack Weinberg
[not found] ` < 199903151256.HAA08065@blastula.phys.columbia.edu >
1999-03-15 13:19 ` craig
[not found] ` < 19990315211232.23607.qmail@deer >
1999-03-15 20:03 ` Zack Weinberg [this message]
1999-03-31 23:46 ` Zack Weinberg
1999-03-31 23:46 ` craig
1999-03-31 23:46 ` Zack Weinberg
1999-03-31 23:46 ` craig
1999-03-15 13:28 ` Joern Rennecke
[not found] ` < 199903152127.VAA32106@phal.cygnus.co.uk >
1999-03-15 20:21 ` Zack Weinberg
[not found] ` < 199903160417.XAA29108@blastula.phys.columbia.edu >
1999-03-16 11:58 ` Joern Rennecke
1999-03-31 23:46 ` Joern Rennecke
1999-03-28 0:13 ` Jeffrey A Law
1999-03-31 23:46 ` Jeffrey A Law
1999-03-31 23:46 ` Zack Weinberg
1999-03-17 20:38 ` Jeffrey A Law
[not found] ` < 14630.921731892@hurl.cygnus.com >
1999-03-18 9:25 ` Zack Weinberg
1999-03-31 23:46 ` Zack Weinberg
1999-03-31 23:46 ` Jeffrey A Law
1999-03-31 23:46 ` Joern Rennecke
1999-03-31 23:46 ` Zack Weinberg
[not found] <199903162144.QAA19514@blastula.phys.columbia.edu>
1999-03-16 14:08 ` Joern Rennecke
1999-03-31 23:46 ` Joern Rennecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199903160403.XAA28775@blastula.phys.columbia.edu \
--to=zack@rabi.columbia.edu \
--cc=craig@jcb-sc.com \
--cc=egcs@egcs.cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).