public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55881] New: #pragma GCC diagnostic ignored ignored when inlining
@ 2013-01-05  0:18 greened at obbligato dot org
  2013-01-05 12:07 ` [Bug c++/55881] " manu at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: greened at obbligato dot org @ 2013-01-05  0:18 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: greened@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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-07-06 22:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-05  0:18 [Bug c++/55881] New: #pragma GCC diagnostic ignored ignored when inlining greened at obbligato dot org
2013-01-05 12:07 ` [Bug c++/55881] " manu at gcc dot gnu.org
2013-01-07 10:08 ` rguenth at gcc dot gnu.org
2013-01-07 21:50 ` greened at obbligato dot org
2013-01-07 21:51 ` greened at obbligato dot org
2013-01-08 11:15 ` manu at gcc dot gnu.org
2021-07-06 21:59 ` cvs-commit at gcc dot gnu.org
2021-07-06 22:02 ` [Bug middle-end/55881] " msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).