Created attachment 1059733 [details] test.c Please see the attached test.c file. There are three types of functions, which should produce the same compiler warnings about function return values, but they do not. I do not understand why. The first line contains a command line to compile the code. The first set of functions, prefixed with "direct_", uses direct 'return' statements, which gcc catches nicely and warns about issues. The second set of functions, prefixed with "macro_", uses GLib's g_return{_val}_if_fail() macros, in the same way as the "direct_" functions, thus I expect to be warned about them. I get no warning here. The last function, my_macro_missing_return_func(), uses cop&pasted g_return_if_fail() macro from /usr/include/glib-2.0/glib/gmessages.h, only renamed to my_return_if_fail(), about which the gcc claims the compiler warning, just as expected. As the macro expansion works in case of the last function, I expect it to work the same in the second set of functions, but it doesn't. I know the macros are used, because I see the warnings in the runtime. $ gcc --version gcc (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
There is a comment at [1]: > I found glib/gmessages.h contains this: > > /* Suppress warnings when GCC is in -pedantic mode and not -std=c99 */ > #if (__GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)) > #pragma GCC system_header > #endif > > > so warnings caused by g_return_if_fail and g_return_val_if_fail are suppressed. but even if I add -pedantic and -std=c99 into the command line, then I'm not warned during the compile time. (Why would anyone disable these warnings anyway?) [1] https://bugzilla.gnome.org/show_bug.cgi?id=753276#c5
(In reply to Milan Crha from comment #1) > but even if I add -pedantic and -std=c99 into the command line, then I'm not > warned during the compile time. It might be just other compiler flags to enable the warnings, because if I manually disable the quoted code then the warnings are shown as expected.
Thinking of it, it's glib's issue, the check doesn't seem to do what it claims to do, thus let's move this upstream: https://bugzilla.gnome.org/show_bug.cgi?id=753310