This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/33572] New: wrong code with -O


> cat bug.cc
#include <vector>
#include <memory>

struct Foo { virtual void f() {} };

int main(int argc, char**)
{
        std::auto_ptr<Foo> foo;
        if (argc) {
                foo.reset(new Foo());
        } else {
                std::vector<int> v;
        }
        Foo* p = foo.release();
        p->f();
}

> g++ -O bug.cc
> a.out
Segmentation fault (core dumped)

I'm using SVN revision 128838 on linux-x86_64.
Without -O or with g++ version 4.2.1 this program works correctly.


-- 
           Summary: wrong code with -O
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wouter dot vermaelen at scarlet dot be


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]