public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57072] New: bogus "is used uninitialized" warning
@ 2013-04-25 18:01 ppluzhnikov at google dot com
  2013-11-19 22:30 ` [Bug c++/57072] " law at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: ppluzhnikov at google dot com @ 2013-04-25 18:01 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 57072
           Summary: bogus "is used uninitialized" warning
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ppluzhnikov@google.com


Google ref: b/8700048

Test:


struct A {
  ~A() __attribute__((noreturn));
  A& stream();
  template <typename T> void operator<<(T&);
};

struct C {
  enum State { S1, S2 };
  static bool Fn(State s) {
    switch (s) {
      case S2: A().stream() << s;
    }
  }
};

void TestFn()
{
  for (int i = 0; i < 2; ++i) {
    C::Fn ? (void) 0 : A().stream() << " ";
    C::Fn(static_cast<C::State>(i));
  }
}



Using g++ (GCC) 4.9.0 20130412 (experimental) (r197936):

g++ -c -Wuninitialized -O2 -fno-tree-vrp t.cc

t.cc: In function ‘void TestFn()’:
t.cc:16:6: warning: ‘s’ is used uninitialized in this function
[-Wuninitialized]
 void TestFn()
      ^

This warning doesn't trigger on 4_7-branch, but a slightly less reduced test
case does, so it's likely not a recent regression.
>From gcc-bugs-return-420972-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Apr 25 18:04:29 2013
Return-Path: <gcc-bugs-return-420972-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 27294 invoked by alias); 25 Apr 2013 18:04:28 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 27268 invoked by uid 48); 25 Apr 2013 18:04:25 -0000
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/57073] New: __builtin_powif (-1.0, k) should be optimized to "1.0 - 2.0 * (K%2)"
Date: Thu, 25 Apr 2013 18:04:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Keywords: missed-optimization
X-Bugzilla-Severity: normal
X-Bugzilla-Who: burnus at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields:
Message-ID: <bug-57073-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg02117.txt.bz2
Content-length: 910


http://gcc.gnu.org/bugzilla/show_bug.cgi?idW073

             Bug #: 57073
           Summary: __builtin_powif (-1.0, k) should be optimized to "1.0
                    - 2.0 * (K%2)"
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


Motivated by PR57071.

In numerical code, it is not unlike to find code of the form "(-1.0) raised to
the power of k", in Fortran: (-1.0)**k.

That translates into:
  __builtin_powif (-1.0e+0, k)
which stays that way even with -O3.

Expected: It gets optimized to "1.0 - 2.0 * (K%2)"


Fortran test case:

real function f(k)
  integer, value :: k
  f = (-1.0)**k
end


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

* [Bug c++/57072] bogus "is used uninitialized" warning
  2013-04-25 18:01 [Bug c++/57072] New: bogus "is used uninitialized" warning ppluzhnikov at google dot com
@ 2013-11-19 22:30 ` law at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: law at redhat dot com @ 2013-11-19 22:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Jeffrey A. Law <law at redhat dot com> ---
Accurate warnings from -Wuninitialized depends on various optimizers being
allowed to do their job.  -fno-tree-vrp in this case disables collpasing a
conditional so a singularity and disables the first jump threading pass.

In combination these two prevent the CFG from being optimized enough to prove
the value can't be used uninitialized.

*** This bug has been marked as a duplicate of bug 42145 ***


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

end of thread, other threads:[~2013-11-19 22:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-25 18:01 [Bug c++/57072] New: bogus "is used uninitialized" warning ppluzhnikov at google dot com
2013-11-19 22:30 ` [Bug c++/57072] " law at redhat dot com

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