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



Michael van der Kolff <mvanderkolff at gmail dot com> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|                            |mvanderkolff at gmail dot

                   |                            |com



--- Comment #30 from Michael van der Kolff <mvanderkolff at gmail dot com> 
2013-01-16 12:39:24 UTC ---

The following is currently (g++ 4.7.2) inlined:

#include <iostream>



using namespace std;



class Foo

{

public:

    void Bar() const

    {

        cout << "Howdy!" << endl;

    }

};



int main()

{

    Foo x;

    auto y = [] (const Foo& z) { z.Bar(); };

    y(x);

    return 0;

}

objdump -D:

--snip --

  400700:       48 83 ec 08             sub    $0x8,%rsp

  400704:       be 0c 09 40 00          mov    $0x40090c,%esi

  400709:       bf a0 0c 60 00          mov    $0x600ca0,%edi

  40070e:       e8 cd ff ff ff          callq  4006e0

<_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>

  400713:       48 89 c7                mov    %rax,%rdi

  400716:       e8 d5 ff ff ff          callq  4006f0

<_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@plt>

  40071b:       31 c0                   xor    %eax,%eax

  40071d:       48 83 c4 08             add    $0x8,%rsp

  400721:       c3                      retq   

  400722:       66 66 66 66 66 2e 0f    data32 data32 data32 data32 nopw

%cs:0x0(%rax,%rax,1)

--snip --

whereas any version with ptr-to-mem fn is not:

...

int main()

{

    Foo x;

    auto y = &Foo::Bar;

    (x.*y)();

    return 0;

}

objdump -D:

--snip --

0000000000400830 <main>:

  400830:       48 83 ec 18             sub    $0x18,%rsp

  400834:       48 8d 7c 24 0f          lea    0xf(%rsp),%rdi

  400839:       e8 42 01 00 00          callq  400980 <_ZNK3Foo3BarEv>

  40083e:       31 c0                   xor    %eax,%eax

  400840:       48 83 c4 18             add    $0x18,%rsp

  400844:       c3                      retq   

  400845:       66 66 2e 0f 1f 84 00    data32 nopw %cs:0x0(%rax,%rax,1)

--snip --

Reply via email to