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++/71207] New: gcc 5.3 and 6.1 generates wrong code with -O2


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71207

            Bug ID: 71207
           Summary: gcc 5.3 and 6.1 generates wrong code with -O2
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vladimir.simonov at acronis dot com
  Target Milestone: ---

Hi,

Quite simple and common pattern:
class Class1
{
public:
  Class1();
  virtual ~Class1();

protected:
  unsigned Field1;
};

class Class2 : public virtual Class1
{
};

class Class3 : public virtual Class1
{
public:
  virtual void Method1() = 0;

  void Method2()
  {
    Method1();
  }
};

class Class4 : public Class2, public virtual Class3
{
public:
  Class4();
  virtual void Method1();
};

void Function1();

void Function2()
{
  Class4 var1;
  var1.Method2();
  Function1();
}

gcc 5.3 and 6.1 for x86_64/i686 with -O2 produces:
.Ltext0:
Function2():
.LFB1:
        subq    $40, %rsp
        movq    %rsp, %rdi
        call    Class4::Class4()
.LVL0:
.LFE1:
.Letext0:
...

var1.Method2() and Function1() calls are not generated.

I've tried both 5.3.0 and 6.1
Please see:
https://gcc.godbolt.org/#compilers:!((compiler:g6,options:'-O2',sourcez:MYGwhgzhAEDC5QIwCgDeyAOBXARiAlsAFzLRwISIAUAlANynQBu%2BATgC5ZgjQB%2B8kSrQaZWAe3YBTYFIAmJMlgB2EfAHMlk2dABi%2BSSFmIGAXxGhB5QQCZoRaNjyFmbTtytI0yM8mQWoHhAAzHYOuATALhxcPAKe6I4RClFuPExi%2BNoAspLsABZiRrTQALzQAAwiZOmZ0Dn5hda0jOhkZPUFRfSMJt7mFIEALKGJznEQ1gA0YU6RLNHu40Feo8SM44PCjPOpzBnZuZ3U3T7INdo6yjL4YkrHIue6V%2Bw3Sk00XmQbzGCsxtu/RAAOg6jS2ZEuSmut3u3mQQAA)),filterAsm:(commentOnly:!t,directives:!t),version:3


Thank you
Vladimir

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