Wireshark-dev: Re: [Wireshark-dev] error: logical && with non-zero constant will always evaluat
On Jan 3, 2013, at 1:40 PM, Jeff Morriss <jeff.morriss.ws@xxxxxxxxx> wrote:
> Jeff Morriss wrote:
>> My (Fedora 10) gcc 4.3.2 was also generating this warning; it would seem that a fair spread of gcc versions seem to have the problem.
>> I added a configure check to stop using -Wlogical-op if the compiler is generating this warning in r46916.
>
> Interestingly the Ubuntu buildbot says it would also get the warning:
>
>> checking whether we can add -Wlogical-op to CFLAGS... yes
>> checking whether -Wlogical-op generates warnings from strchr()... yes
Which means that
#include <string.h>
int
foo(char *sep, int c)
{
if (strchr (sep, c) != NULL)
return 1;
else
return 0;
}
int
main(int argc, char **argv)
{
return foo(\"<\", 'a');
}
fails to compile with the CFLAGS value at the time the test is done, plus -Werror; it could be failing for some other reason. To quote the comment when I finally got it working for -Wshadow:
Declare foo() before defining it - if we configure with
--enable-extra-gcc-checks, given that we're building with -Werror (so
that we find out whether the compiler issues a warning for a particular
construct), we have to avoid constructs that will provoke *other*
warnings.
so the code in question has to avoid whatever other warnings are being used, and the Ubuntu buildbot builds with --enable-extra-gcc-checks, so it warns about functions not declared with prototypes before they're defined. I've checked in a change to declare foo() before it's defined; we'll see whether that fixes it.