GNOME Bugzilla – Bug 767998
tautological-compare warnings/errors when building tests with recent GCC
Last modified: 2016-07-04 14:21:27 UTC
I updated to Fedora 24 (gcc 6.1.1) and get those warnings (handled as errors) when running "make check". gst/gstinfo.c: In function ‘info_ptr_format_printf_extension’: gst/gstinfo.c:59:26: error: self-comparison always evaluates to true [-Werror=tautological-compare] gst_debug_remove_log_function (gst_debug_log_default); ^~ gst/gstinfo.c:134:33: error: self-comparison always evaluates to true [-Werror=tautological-compare] gst_debug_add_log_function (gst_debug_log_default, NULL, NULL); ^~ gst/gstinfo.c: In function ‘info_segment_format_printf_extension’: gst/gstinfo.c:145:26: error: self-comparison always evaluates to true [-Werror=tautological-compare] gst_debug_remove_log_function (gst_debug_log_default); ^~ gst/gstinfo.c:212:33: error: self-comparison always evaluates to true [-Werror=tautological-compare] gst_debug_add_log_function (gst_debug_log_default, NULL, NULL); ^~ gst/gstinfo.c: In function ‘info_log_handler’: gst/gstinfo.c:222:36: error: self-comparison always evaluates to true [-Werror=tautological-compare] removed = gst_debug_remove_log_function (gst_debug_log_default); ^~ gst/gstinfo.c: In function ‘info_old_printf_extensions’: gst/gstinfo.c:292:26: error: self-comparison always evaluates to true [-Werror=tautological-compare] gst_debug_remove_log_function (gst_debug_log_default); ^~ gst/gstinfo.c:327:33: error: self-comparison always evaluates to true [-Werror=tautological-compare] gst_debug_add_log_function (gst_debug_log_default, NULL, NULL); ^~ cc1: all warnings being treated as errors Makefile:2469: recipe for target 'gst/gstinfo.o' failed
Looks like it's because of this: https://cgit.freedesktop.org/gstreamer/gstreamer/tree/gst/gstinfo.h#n427 #define gst_debug_remove_log_function(func) \ (func == gst_debug_log_default) ? \ gst_debug_remove_log_function(NULL) : \ gst_debug_remove_log_function(func) What's the point of this macro exactly? We have the same the same logic implemented in the function: if (func == NULL) func = gst_debug_log_default;
*** This bug has been marked as a duplicate of bug 764526 ***
I didn't see this bug until now. To answer your question in comment 1, it's to do with the fact that we can't compare the function pointer directly inside the function, because the function pointer GStreamer sees internally can be different to value of the globally available function entry point and they don't match. See the commits where the macro was added.