> cat -n bug.cc
     1  struct Base {
     2          virtual ~Base() {}
     3          virtual void f() = 0;
     4  };
     5  struct Derived : Base {
     6          Derived();
     7          virtual void f() {}
     8  };
     9  struct Foo {
    10          Foo(Base&);
    11  };
    12
    13  Derived::Derived() {
    14          Foo foo(*this);
    15  }
    16  Foo::Foo(Base& base) {
    17          base.f();
    18  }
    19  int main() {
    20          Derived d;
    21  }

> g++ -g -O2 -fgcse-sm bug.cc
> ./a.out
Segmentation fault (core dumped)

#0  0x0000000000000000 in ?? ()
#1  0x0000000000400775 in Derived (this=0x7fff2fc93390) at bug.cc:14
#2  0x00000000004007ec in main () at bug.cc:20


I'm using gcc revision 135109 on linux x86_64.


-- 
           Summary: wrong code with  -O2 -fgcse-sm
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          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=36185

Reply via email to