public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "foom at fuhm dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/53364] New: [4.7/4.8 Regression] Wrong code generation
Date: Tue, 15 May 2012 19:24:00 -0000	[thread overview]
Message-ID: <bug-53364-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             Bug #: 53364
           Summary: [4.7/4.8 Regression] Wrong code generation
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: foom@fuhm.net


On the following code, minimized from a much larger program:

test.cpp
=====================
#include <algorithm>

struct A
{
    int m_x;

    explicit A(int x) : m_x(x) {}
    operator int() const { return m_x; }
};

struct B : public A
{
 public:
    explicit B(int x)
    : A(x) {}
};

int data = 1;

int main() {
    B b = B(10);
    b = std::min(b, B(data));
    return int(b);
}
=================

Running: g++ -O2 -c test.cpp
With gcc version: g++ (Debian 4.7.0-8) 4.7.0
(which says it's built from r187339 on the gcc 4.7 branch).
On architecture: x86-64

The program ought to return 1, but instead, it returns randomness. Running
valgrind confirms that this program is using uninitialized values.

Testing with the debian gcc-snapshot package (trunk rev 187013) shows the same
bug.
Testing with the debian gcc 4.6.3 package does not show the bug.
Using -O1 does not show the bug.
Using -O1 -fstrict-aliasing shows the bug.


             reply	other threads:[~2012-05-15 19:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-15 19:24 foom at fuhm dot net [this message]
2012-05-16  4:13 ` [Bug c++/53364] " foom at fuhm dot net
2012-05-16  4:28 ` pinskia at gcc dot gnu.org
2012-05-16  4:54 ` foom at fuhm dot net
2012-05-16  8:54 ` glisse at gcc dot gnu.org
2012-05-16 10:32 ` [Bug tree-optimization/53364] " rguenth at gcc dot gnu.org
2012-05-16 10:38 ` rguenth at gcc dot gnu.org
2012-05-16 11:22 ` rguenth at gcc dot gnu.org
2012-05-16 13:11 ` rguenth at gcc dot gnu.org
2012-05-16 13:13 ` rguenth at gcc dot gnu.org
2012-05-16 13:19 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-53364-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).