This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
warning from assert
- From: Michael Morrell <morrell at alumni dot ucsd dot edu>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 30 Apr 2008 15:53:59 -0700 (PDT)
- Subject: warning from assert
- Reply-to: morrell at alumni dot ucsd dot edu
I'm using gcc 4.2.1 and getting a warning from the use of the assert macro
that I'd like to avoid. My source looks like:
=========================================
#include <assert.h>
void foo()
{
int *a;
assert(&a);
}
=========================================
When I run "gcc -Wall -c assert.c" on this, I get:
warning: the address of 'a' will always evaluate as 'true'
While the warning is correct and helpful in many situations, the problem
is that in my real code, the assert macro is inside another macro which
gets used in a lot of places and I believe that for some callers, the
assert check is useful, so I don't want to just delete the use of assert.
Any suggestions?
Thanks,
Michael
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ