This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Aug 2008 12:53:52 -0000
- Subject: [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
- References: <bug-36299-6373@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from manu at gcc dot gnu dot org 2008-08-23 12:53 -------
Andrew, how could we detect that it is a decayed array?
I think we would like to warn for
if (a == (void *) 0)
but not for
if ((void *)a == 0)
or even if possible not for
if (&a[0] == 0)
Vincent,
this warning was added on purpose, because probably someone requested it. I
don't see that it is very different from the documented case of using the
address of a function in a conditional.
You should be able to work-around the macro case by casting the array to (char
*) or perhaps casting to (void *) ? That said, we would like to not warn within
macros for a wide range of warnings but we don't have the infrastructure to do
that yet.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299