This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]