Mini-patch for cccp.c
Thomas Koenig
ig25@mvmap66.ciw.uni-karlsruhe.de
Wed Oct 1 02:43:00 GMT 1997
Jeffrey A Law wrote:
> > - This patch shuts up a spurious warning by checkergcc (which is why I
> > did it in the first place)
>What is the warning?
The problem is that checkergcc warns about
typedef struct {
int a; char b;
} foo_type;
foo_type bar()
{
foo_type res;
res.a = 19; res.b = 'a';
return res;
}
int main()
{
foo_type c;
c = bar();
printf("a = %d, b = %c\n",c.a,c.b);
return 0;
}
with a 'read uninitialized bytes' warning in the 'return res' line of
bar().
The reason is clear: sizeof(res) is 8 because of padding, and 'return res'
copies 8 bytes onto the caller's stack in two 4-byte words. checkergcc,
which only manipulates the assembler, has no way of knowing that the three
extra bytes don't mean anything, and warns about them.
Obviously, this is a Checker artifact. Checker is immensely useful
otherwise (I found the other two bugs I reported recently with it), but
its output can be rather overwhelming. Therefore, I think it may be
worth making this particular change which doesn't hurt anything else,
AFAIK, just to shut it up in this particular instance.
--
Thomas Koenig, Thomas.Koenig@ciw.uni-karlsruhe.de, ig25@dkauni2.bitnet.
The joy of engineering is to find a straight line on a double
logarithmic diagram.
More information about the Gcc
mailing list