Article View: gnu.gcc.bug
Article #66gcc-2.3.1: arrays of structs+assign in cond+unfinished fixincludes
From: Orest Zborowski COMP
Date: Tue, 03 Nov 1992 18:02
Date: Tue, 03 Nov 1992 18:02
54 lines
2145 bytes
2145 bytes
I have a few comments about gcc-2.3.1 (-Wall -ansi, sunos-sun4-4.1):
o Arrays of unbracketed struct declarations are given warnings. According
to ANSI C, this is perfectly legal, so a warning here is unwarranted.
o Conditionals with a single assignment are warned to surround the
assignment with parenthesis. Since the assignment is the only expression
in the conditional, this is overkill.
o Fixincludes doesn't fix all the #endif's with trailing garbage from the
headers in /usr/include. Using -Wall and -ansi we had to manually strip
tens of headers.
The following sample shows the first two problems:
503!% cat florp.c
#include <stdio.h>
static struct
{
int i;
char *s;
} arr[] =
{
1, "hello",
2, "there"
};
int
main()
{
int v;
if (v = arr[0].i)
printf("nonzero");
return 0;
}
504!% gcc -Wall -ansi -c florp.c
florp.c:11: warning: aggregate has a partly bracketed initializer
florp.c:11: warning: aggregate has a partly bracketed initializer
florp.c: In function `main':
florp.c:18: warning: suggest parentheses around assignment used as truth value
florp.c:19: warning: implicit declaration of function `printf'
We use gcc -ansi -Wall as a sort of compile-time lint, and most of gcc's
warnings are well-founded. I believe the examples above could be used in
some more stringent lint behavior. Please correct me if I'm wrong (since
I'm new to the gcc bug group and discussions).
zorst
[obz@raster.Kodak.COM]
--
zorst (orest zborowski)
[obz@raster.Kodak.COM]
Technical Details
Message-ID:
<1992Nov3.180242.3404@sisd.kodak.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!ogicse!emory!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sisd.kodak.COM!obzShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!emory!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sisd.kodak.COM!obz From: obz@sisd.kodak.COM (Orest Zborowski COMP) Newsgroups: gnu.gcc.bug Subject: gcc-2.3.1: arrays of structs+assign in cond+unfinished fixincludes Message-ID: <1992Nov3.180242.3404@sisd.kodak.com> Date: 3 Nov 92 18:02:42 GMT Article-I.D.: sisd.1992Nov3.180242.3404 Sender: gnulists@ai.mit.edu Distribution: gnu Organization: Printer Products Eastman Kodak Lines: 54 Approved: bug-gcc@prep.ai.mit.edu