Thread View: gnu.gcc.bug
2 messages
2 total messages
Started by Orest Zborowski COMP
Tue, 03 Nov 1992 18:02
gcc-2.3.1: arrays of structs+assign in cond+unfinished fixincludes
Author: 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]
Re: gcc-2.3.1: arrays of structs+assign in cond+unfinished fixincludes
Author: Paul Eggert
Date: Wed, 04 Nov 1992 00:11
Date: Wed, 04 Nov 1992 00:11
22 lines
1545 bytes
1545 bytes
obz@raster.Kodak.COM writes: >o Arrays of unbracketed struct declarations are given warnings. According > to ANSI C, this is perfectly legal, so a warning here is unwarranted. Actually, GCC 2.3.1 is following the suggestion of the ANSI C standard here. See ANSI X3.159-1989, Appendix E ``Common Warnings'', page 198, 10th warning. To turn off this warning, omit `-W'. >o Conditionals with a single assignment are warned to surround the > assignment with parenthesis. This warning can be quite useful to catch common C coding errors like `if (a = b)' where `if (a == b)' was meant. To turn off the warning, use `-Wall -Wno-parentheses' instead of just `-Wall'. >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. This is fixed by the fixincludes patch that I posted yesterday (Message-ID: <9211030433.AA05731@farside.twinsun.com>).
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads