GNOME Bugzilla – Bug 753310
Remove `#pragma GCC system_header` from gmessages.h
Last modified: 2015-09-22 14:16:17 UTC
The gmessages.h contains a #pragma GCC system_header pragma, which hides compiler warnings when macros like g_return_if_fail() is used in a function which should return value (or vice versa), or when an incorrect value type is returned in the macro. Such compiler warnings help to identify dumb coding issues. This change had been added in commit 662bf991, at the end of 2001. I believe it's time to revert the commit and let the compiler do its job.
Here's a downstream bug report where can be found a test program too. https://bugzilla.redhat.com/show_bug.cgi?id=1250848
2001? GCC did warn about this just fine until recently.
(In reply to Michael Natterer from comment #2) > 2001? GCC did warn about this just fine until recently. It used to, but stopped doing that since GCC 4.8 or 4.9. Clang still warns correctly. I think the commit in question should be reverted, otherwise we're missing valuable warning messages.
Created attachment 311851 [details] [review] Revert use of the system_header GCC pragma This reverts commit 662bf991c08b16dea8a36026243b311f6cdb17f1. It is not a straight up revert because the old commit involved various long since removed ChangeLog files and we'd end up mudding the patch. The system_header GCC pragma is breaking warnings in the various g_return_* macros; GCC stopped warning when using a macro with a return value in a function that returns void, as well as when using a macro with no return value in a function that has a non-void return value. Suppressing this kind of warnings is not a good idea. Other compilers are unaffected, even ones like Clang with a GCC compatibility layer. Given the fact that the original commit was added 14 years ago as a workaround in the old days of GTK+ 1.2, I think it's safe to drop it.
Review of attachment 311851 [details] [review]: I suspect this is going to have some fallout for people who use -Werror, but they signed up for pain.
Thanks for the review, Colin. The warnings have always been there, so I hope nobody using -Werror is relying on GLib/GCC not warning any more. Also, auto-builders and jhbuild users should be shielded by gnome-common/m4-common. At least, I hope. Attachment 311851 [details] pushed as ab26dd5 - Revert use of the system_header GCC pragma