Article View: gnu.gcc.bug
Article #2397Re: gcc 1.34 -ansi -strict -pedantic
From: Geoff Rimmer
Date: Tue, 14 Mar 1989 03:22
Date: Tue, 14 Mar 1989 03:22
86 lines
3141 bytes
3141 bytes
In article <8903061953.AA25822@hector.homer.nj.att.com> ulysses!north@RESEARCH.ATT.COM writes:
> gcc 1.34 -ansi -strict -pedantic
> doesn't warn about functions that fail
> to return a value, as in
>
> hector> cat t.c
>
> typedef struct x_t {
> int i;
> } x_t;
>
> x_t f() {
> }
>
> hector> gcc -c -ansi -strict -pedantic t.c
> hector>
>
> an x_t could just as well be an int.
> i know many programmers are sloppy about this
> but i'd think this combination of command
> line options would trigger a warning at least.
I don't believe there *is* a -strict switch to gcc v1.34. I just had
a quick glance at gcc.c and the info file, and still couldn't find any
mention of it. The switches that you should use are the -W flags, in
particular, the -Wreturn-type switch. If you use -Wall (as I always
do now!), you get all the warnings that GCC can find (except for one).
`-Wimplicit'
Warn whenever a function is implicitly declared.
`-Wreturn-type'
Warn whenever a function is defined with a return-type that
defaults to `int'. Also warn about any `return' statement with
no return-value in a function whose return-type is not `void'.
`-Wunused'
Warn whenever a local variable is unused aside from its
declaration.
`-Wcomment'
Warn whenever a comment-start sequence `/*' appears in a comment.
`-Wall'
All of the above `-W' options combined.
`-Wwrite-strings'
Give string constants the type `const char[LENGTH]' so that
copying the address of one into a non-`const' `char *' pointer
will get a warning. These warnings will help you find at
compile time code that can try to write into a string constant,
but only if you have been very careful about using `const' in
declarations and prototypes. Otherwise, it will just be a
nuisance; this is why we did not make `-Wall' request these
warnings.
geoff% cat t.c
typedef struct x_t
{
int i;
} x_t;
x_t f()
{
}
geoff% gcc -c -ansi -pedantic t.c
[ no warnings ]
geoff% gcc -c -Wreturn-type -ansi -pedantic t.c
t.c: In function f:
t.c:10: warning: control reaches end of non-void function
Geoff
------------------------------------------------------------
Geoff Rimmer, Computer Science, Warwick University, England.
geoff@uk.ac.warwick.emerald
"You can't eat a canvus or a piece of rock."
"I dunno, you could if you were drunk enough and had enough
ketchup"
- Filthy, Rich and Catflap, 1986.
------------------------------------------------------------
Technical Details
Message-ID:
<1601@ubu.warwick.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!mcvax!ukc!warwick!geoffReferences:
<8903061953.AA25822@hector.homer.nj.att.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!mcvax!ukc!warwick!geoff From: geoff@cs.warwick.ac.uk (Geoff Rimmer) Newsgroups: gnu.gcc.bug Subject: Re: gcc 1.34 -ansi -strict -pedantic Message-ID: <1601@ubu.warwick.UUCP> Date: 14 Mar 89 03:22:09 GMT References: <8903061953.AA25822@hector.homer.nj.att.com> Sender: news@warwick.UUCP Distribution: gnu Organization: Computer Science, Warwick University, UK Lines: 86 In-reply-to: ulysses!north@RESEARCH.ATT.COM's message of 8 Mar 89 20:55:31 GMT