public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53364] New: [4.7/4.8 Regression] Wrong code generation
@ 2012-05-15 19:24 foom at fuhm dot net
  2012-05-16  4:13 ` [Bug c++/53364] " foom at fuhm dot net
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: foom at fuhm dot net @ 2012-05-15 19:24 UTC (permalink / raw)
  To: gcc-bugs

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.


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

end of thread, other threads:[~2012-05-16 13:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-15 19:24 [Bug c++/53364] New: [4.7/4.8 Regression] Wrong code generation foom at fuhm dot net
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

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