This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
Compiling the following code with gcc-4.3 -Wlogical-op -O1 int main () { char *s, t; strchr (s, t); } leads to this warning: test2.c: In function ‘main’: test2.c:7: warning: logical ‘&&’ with non-zero constant will always evaluate as true This is because libc defines strchr to a macro in bits/string.h. It looks to me like gcc should not warn about optimizations like __builtin_constant_p optimizations as those are diectly targeted at being optimized out.
Well also I think glibc should not need to optimise strchr really and let the compiler do it.
We need a reproducible preprocessed testcase. See http://gcc.gnu.org/bugs.html#detailed
Benjamin, note that -Wlogical-op will be enabled by -Wextra in GCC 4.5. I am willing to give it a try to fix this before 4.5 is released. However, I cannot reproduce this problem, so please, provide a preprocessed testcase.
I cannot reproduce this anymore with gcc 4.3.3 from Ubuntu 9.04, so I consider this fixed.
FIXED per previous comment.
I get this error when building swfdec with gcc 4.4.2 on Fedora 12.
Also tried the simple test case described in the bug description, although it needs to add #include <string.h> at the top. The warning is still there.
Created an attachment (id=19148) [edit] Preprocessed source file Created a preprocessed source file producing the warning.
(In reply to comment #6) > I get this error when building swfdec with gcc 4.4.2 on Fedora 12. It is a warning that you need to enable with -Wlogical-op explicitly. I cannot reproduce the preprocessed testcase with GCC 4.5 rev 150311. If you can reproduce it with a more recent revision, please let us know. Since this is not a regression (it was a new warning in GCC 4.3), I don't think anyone will try to fix it in GCC 4.3.x or GCC 4.4.x. Now that we have a preprocessed testcase, I will try to reduce it and add it to the testsuite to avoid regressing here.
Now that we have a preprocessed testcase, I will try to reduce it and add it to the testsuite to avoid regressing here.