assertion warnings
Dave Gotwisner
Dave.Gotwisner@harmonicinc.com
Tue Nov 15 20:51:00 GMT 2005
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;
}
More information about the Gcc-help
mailing list