This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: assertion warnings
- From: "Dave Gotwisner" <Dave dot Gotwisner at harmonicinc dot com>
- To: "bill" <bill dot pursell at gmail dot com>,<gcc-help at gcc dot gnu dot org>
- Date: Tue, 15 Nov 2005 12:51:36 -0800
- Subject: RE: assertion warnings
Nothing invalid about any of them. Assert is a macro, not a function
with a prototype. The first and third asserts are potentially dangerous
(they won't necessarily do what you think because of normal macro
expansion rules), but nothing invalid at compile time.
What is it really (in English) that you are trying to do?
Dave
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of bill
Sent: Tuesday, November 15, 2005 12:19 PM
To: gcc-help@gcc.gnu.org
Subject: assertion warnings
Is there any way to get gcc to generate warnings for the following code?
-Wall gives no complaints at all.
I expect that it's asking too much to get a warning for the first
assertion, but
the other two seem to be pretty obvious candidates for a warning.
#include <assert.h>
int
foo(int *x)
{
*x = *x+1;
return *x;
}
int
main()
{
int x;
assert(foo(&x));
assert(x=2);
assert(x++);
return 0;
}