http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55881
Bug #: 55881 Summary: #pragma GCC diagnostic ignored ignored when inlining Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: gree...@obbligato.org The following testcase causes g++ 4.7.1 to emit a warning even though it contains a pragma to ignore uninitialized variables. struct I { int i; int foo(struct I *n) { // Warning points here. return n->i + 10; } I(void) : i(5) {} }; int main(int argc, char **) { struct I i, *n; if (argc > 10) { n = new I; // Fine. i.i = i.foo(n); } if (argc > 2) { #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // Still get a warning. return i.foo(n); #pragma GCC diagnostic pop } return 0; } This is the shortest testcase I could produce to demonstrate the problem. I have seen this kind of problem when passing what gcc things are possibly uninitialized variables as arguments to functions which are inlined. Adding a pragma inside the inlined function suppresses the warning but that's a much bigger hammer than placing the pragma around the call site. I do not want to miss possible errors in other contexts where the function is called.