On Mon, Jul 04, 2016 at 10:17:24AM +0530, Numan Siddique wrote: > I am seeing the below compiler warnings with GCC version 6.1 on Fedora 24. > > $gcc --version > gcc (GCC) 6.1.1 20160621 (Red Hat 6.1.1-3) > > libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I ../include -I ./include > -I ../lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare > -Wpointer-arith -Wswitch-enum -Wunused-parameter -Wbad-function-cast > -Wcast-align -Wmissing-prototypes -Wmissing-field-initializers > -fno-strict-aliasing -Werror -g -O2 -MT lib/classifier.lo -MD -MP -MF > lib/.deps/classifier.Tpo -c ../lib/classifier.c -o lib/classifier.o > ../lib/classifier.c: In function ‘cls_match_alloc’: > ../lib/classifier.c:96:53: error: self-comparison always evaluates to true > [-Werror=tautological-compare] > *CONST_CAST(const struct cls_rule **, &cls_match->cls_rule) = rule;
I think that this and similar warnings are coming from the definition of BUILD_ASSERT_TYPE in util.h. It does compare a pointer to a cast version of itself, intentionally, to provoke an error if their types are sufficiently different: #define BUILD_ASSERT_TYPE(POINTER, TYPE) \ ((void) sizeof ((int) ((POINTER) == (TYPE) (POINTER)))) I'm not sure how to best suppress this particular warning, especially since I don't have a copy of GCC 6.x here. It might be possible to do it by making the expression even more obvious: diff --git a/include/openvswitch/util.h b/include/openvswitch/util.h index 363fa39..2835def 100644 --- a/include/openvswitch/util.h +++ b/include/openvswitch/util.h @@ -70,7 +70,7 @@ OVS_NO_RETURN void ovs_assert_failure(const char *, const char *, const char *); * bool" warning from "sparse" (see * http://permalink.gmane.org/gmane.comp.parsers.sparse/2967). */ #define BUILD_ASSERT_TYPE(POINTER, TYPE) \ - ((void) sizeof ((int) ((POINTER) == (TYPE) (POINTER)))) + ((void) sizeof ((int) (1 || (POINTER) == (TYPE) (POINTER)))) /* Casts 'pointer' to 'type' and issues a compiler warning if the cast changes * anything other than an outermost "const" or "volatile" qualifier. Maybe a build assertion on __builtin_types_compatible_p() would work, but I couldn't quickly figure out a good way. _______________________________________________ discuss mailing list discuss@openvswitch.org http://openvswitch.org/mailman/listinfo/discuss