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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2016-01-29 00:00:00         |2019-4-8

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Giovanni Deretta from comment #0)
> I would expect call(wV&) to generate the same code as call(oV&).

Except of course it should be a direct call to V::foo(), not oV::foo().

As I showed in Bug 69445 the devirtualization does happen when the final
overrider is in the derived class:

struct Base {
  virtual void foo() const {};
  virtual void bar() const {}
};

struct C final : Base {
  void foo() const { }
};

void func(const C & c) {
  c.foo();  // optimized away
  c.bar();
}

It doesn't happen when the final overrider comes from the base.

Reply via email to