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++/67184] New: Missed optimization with C++11 final specifier


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

            Bug ID: 67184
           Summary: Missed optimization with C++11 final specifier
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gpderetta at gmail dot com
  Target Milestone: ---

struct V {
 virtual void foo(); 
};

struct wV final : V {

};

struct oV final : V {
  void foo();

};

void call(V& x)
{
  x.foo();
}

void call(wV& x)
{
  x.foo();
}

void call(oV& x)
{
  x.foo();
}

# compile with g++ -O3 -std=c++11 

gcc 5.1 and 5.2 on x86-64 generate:

call(V&):
        movq    (%rdi), %rax
        jmp     *(%rax)
call(wV&):
        movq    (%rdi), %rax
        jmp     *(%rax)
call(oV&):
        jmp     oV::foo()

I would expect call(wV&) to generate the same code as call(oV&).

FWIW Clang generates the expected code since about 3.5.


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