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

* [Bug c++/55881] #pragma GCC diagnostic ignored ignored when inlining
  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 ` manu at gcc dot gnu.org
  2013-01-07 10:08 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2013-01-05 12:07 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55881

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2013-01-05 12:07:31 UTC ---
What is the output of GCC?


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

* [Bug c++/55881] #pragma GCC diagnostic ignored ignored when inlining
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-01-07 10:08 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55881

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-01-07
     Ever Confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> 2013-01-07 10:08:32 UTC ---
This is because uninitialized var usage is warned during optimization and
inlining has no way of handling the diagnostic pragma (I even doubt it works
very well during optimization - it's at most function granular there).

Well - confirmed.  Unlikely to be fixed.


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

* [Bug c++/55881] #pragma GCC diagnostic ignored ignored when inlining
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: greened at obbligato dot org @ 2013-01-07 21:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55881

--- Comment #3 from David Greene <greened at obbligato dot org> 2013-01-07 21:49:58 UTC ---
(In reply to comment #1)
> What is the output of GCC?

warning.cpp: In function 'int main(int, char**)':
warning.cpp:5:19: warning: 'n' may be used uninitialized in this function
[-Wmaybe-uninitialized]
warning.cpp:13:16: note: 'n' was declared here


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

* [Bug c++/55881] #pragma GCC diagnostic ignored ignored when inlining
  2013-01-05  0:18 [Bug c++/55881] New: #pragma GCC diagnostic ignored ignored when inlining greened at obbligato dot org
                   ` (2 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: greened at obbligato dot org @ 2013-01-07 21:51 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55881

--- Comment #4 from David Greene <greened at obbligato dot org> 2013-01-07 21:50:51 UTC ---
(In reply to comment #2)

> Well - confirmed.  Unlikely to be fixed.

That's _very_ unfortunate.  It makes the pragma almost useless in practice.


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

* [Bug c++/55881] #pragma GCC diagnostic ignored ignored when inlining
  2013-01-05  0:18 [Bug c++/55881] New: #pragma GCC diagnostic ignored ignored when inlining greened at obbligato dot org
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2013-01-08 11:15 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55881

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2013-01-08 11:14:49 UTC ---
(In reply to comment #4)
> (In reply to comment #2)
> 
> > Well - confirmed.  Unlikely to be fixed.
> 
> That's _very_ unfortunate.  It makes the pragma almost useless in practice.

The pragma can only work if it somehow knows that location 5:19 is "expanded"
(inlined) from the location of "return i.foo(n)" since the code checks that the
location included in the warning is within the range of the pragma and "5:19"
is clearly not.

This could be implement in the same way as we currently handle macro
expansions, however, it won't be a  trivial amount of work, and it is quite
unlikely that any current developer has the free time and the interest
necessary to do it themselves.

If you really want this feature, you have to either try to implement it
yourself or convince someone to do it for you. Or you may do "n = n" and
silence the warning.


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

* [Bug c++/55881] #pragma GCC diagnostic ignored ignored when inlining
  2013-01-05  0:18 [Bug c++/55881] New: #pragma GCC diagnostic ignored ignored when inlining greened at obbligato dot org
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-06 21:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55881

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:e8db5f70f27b6de8139339ef1866eaa153c2bf67

commit r12-2092-ge8db5f70f27b6de8139339ef1866eaa153c2bf67
Author: Martin Sebor <msebor@redhat.com>
Date:   Tue Jul 6 15:58:02 2021 -0600

    Add test for [PR55881].

            PR c++/55881

    gcc/testsuite/ChangeLog:

            * g++.dg/warn/uninit-pr55881.C: New test.

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

* [Bug middle-end/55881] #pragma GCC diagnostic ignored ignored when inlining
  2013-01-05  0:18 [Bug c++/55881] New: #pragma GCC diagnostic ignored ignored when inlining greened at obbligato dot org
                   ` (5 preceding siblings ...)
  2021-07-06 21:59 ` cvs-commit at gcc dot gnu.org
@ 2021-07-06 22:02 ` msebor at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-06 22:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55881

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.2.0, 11.1.0, 4.7.0,
                   |                            |4.8.4, 4.9.4, 5.5.0, 6.4.0,
                   |                            |7.2.0, 8.3.0, 9.1.0
                 CC|                            |msebor at gcc dot gnu.org
   Target Milestone|---                         |12.0
             Status|NEW                         |RESOLVED
          Component|c++                         |middle-end
         Resolution|---                         |FIXED

--- Comment #10 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed for GCC 12 by r12-2087 and related.

^ 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).