gcc (gcc-4.8.2-1.fc20.x86_64) seems to be not noticing a return-without-value when it occurs inside the expansion of glib's g_return_if_fail() macro: danw@laptop:tmp> cat foo.c #include <glib.h> int main (int argc, char **argv) { g_return_if_fail (argc == 1); return 0; } danw@laptop:tmp> gcc -Wall -c foo.c `pkg-config --cflags --libs glib-2.0` danw@laptop:tmp> echo $? 0 If you force it to expand the macro first, it does notice: danw@laptop:tmp> gcc -E -o foo-expanded.c foo.c `pkg-config --cflags glib-2.0` danw@laptop:tmp> tail -9 foo-expanded.c # 2 "foo.c" 2 int main (int argc, char **argv) { do{ if (argc == 1) { } else { g_return_if_fail_warning (((gchar*) 0), __PRETTY_FUNCTION__, "argc == 1"); return; }; }while (0); return 0; } danw@laptop:tmp> gcc -Wall -c foo-expanded.c `pkg-config --cflags --libs glib-2.0` foo.c: In function ‘main’: foo.c:6:108: error: ‘return’ with no value, in function returning non-void [-Werror=return-type] g_return_if_fail (argc == 1); ^
That is intentional, glib.h is in a system header directory and thus the problem exists in a macro from a system header, warnings for system headers are as documented disabled by default, you need -Wsystem-headers to request it.
ah, oh yeah, i remember wanting that functionality (for *other people's* headers) in the past The problem here is that it's not a bug in the system header, it's that my code is calling the wrong macro. (It should be using g_return_val_if_fail(), not g_return_if_fail().) Not sure if there's any easy fix for this that wouldn't break other cases...