{"id":6808,"date":"2018-02-26T15:53:10","date_gmt":"2018-02-26T06:53:10","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6808"},"modified":"2018-02-26T15:53:10","modified_gmt":"2018-02-26T06:53:10","slug":"%e4%bb%ae%e6%83%b3%e9%96%a2%e6%95%b0%e3%81%ae%e3%82%aa%e3%83%bc%e3%83%90%e3%83%bc%e3%83%a9%e3%82%a4%e3%83%89%e3%81%ab-final-%e3%82%92%e4%bb%98%e3%81%91%e3%82%8b%e3%81%a8%e9%96%93%e6%8e%a5call%e3%81%8c","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6808","title":{"rendered":"\u4eee\u60f3\u95a2\u6570\u306e\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u306b final \u3092\u4ed8\u3051\u308b\u3068\u9593\u63a5call\u304c\u524a\u9664\u3055\u308c\u308b"},"content":{"rendered":"<p>C++11 \u306b\u306f\u4eee\u60f3\u95a2\u6570\u3092\u305d\u308c\u4ee5\u4e0a\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3067\u304d\u306a\u3044\u3088\u3046\u306b\u3059\u308b final \u3068\u3044\u3046\u6307\u5b9a\u304c\u66f8\u3051\u307e\u3059\u304c\u3001final \u304c\u4ed8\u3044\u3066\u3044\u308b\u3068\u547c\u3076\u3068\u304d\u306b vtable \u3092\u53c2\u7167\u3057\u3066\u9593\u63a5call\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u76f4\u63a5\u547c\u3076\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u3068\u308a\u3042\u3048\u305a GCC \u306e\u5834\u5408\uff09<\/p>\n<p><!--more--><\/p>\n<blockquote>\n<pre>\r\n[umezawa@umezawa-cent7:pts\/0 ~]$ cat a.cc\r\nstruct A {\r\n        virtual void foo();\r\n};\r\n\r\nstruct B : public A {\r\n        virtual void foo() final;\r\n};\r\n\r\nstruct C : public A {\r\n        virtual void foo();\r\n};\r\n\r\nvoid bar(B* b)\r\n{\r\n        b->foo();\r\n}\r\n\r\nvoid baz(C* c)\r\n{\r\n        c->foo();\r\n}\r\n[umezawa@umezawa-cent7:pts\/0 ~]$ g++ -std=c++11 -S -o- -O0 a.cc\r\n        .file   \"a.cc\"\r\n        .text\r\n        .globl  _Z3barP1B\r\n        .type   _Z3barP1B, @function\r\n_Z3barP1B:\r\n.LFB0:\r\n        .cfi_startproc\r\n        pushq   %rbp\r\n        .cfi_def_cfa_offset 16\r\n        .cfi_offset 6, -16\r\n        movq    %rsp, %rbp\r\n        .cfi_def_cfa_register 6\r\n        subq    $16, %rsp\r\n        movq    %rdi, -8(%rbp)\r\n        movq    -8(%rbp), %rax\r\n        movq    %rax, %rdi\r\n        call    _ZN1B3fooEv\r\n        leave\r\n        .cfi_def_cfa 7, 8\r\n        ret\r\n        .cfi_endproc\r\n.LFE0:\r\n        .size   _Z3barP1B, .-_Z3barP1B\r\n        .globl  _Z3bazP1C\r\n        .type   _Z3bazP1C, @function\r\n_Z3bazP1C:\r\n.LFB1:\r\n        .cfi_startproc\r\n        pushq   %rbp\r\n        .cfi_def_cfa_offset 16\r\n        .cfi_offset 6, -16\r\n        movq    %rsp, %rbp\r\n        .cfi_def_cfa_register 6\r\n        subq    $16, %rsp\r\n        movq    %rdi, -8(%rbp)\r\n        movq    -8(%rbp), %rax\r\n        movq    (%rax), %rax\r\n        movq    (%rax), %rax\r\n        movq    -8(%rbp), %rdx\r\n        movq    %rdx, %rdi\r\n        call    *%rax\r\n        leave\r\n        .cfi_def_cfa 7, 8\r\n        ret\r\n        .cfi_endproc\r\n.LFE1:\r\n        .size   _Z3bazP1C, .-_Z3bazP1C\r\n        .ident  \"GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-16)\"\r\n        .section        .note.GNU-stack,\"\",@progbits\r\n<\/pre>\n<\/blockquote>\n<p>\u8208\u5473\u6df1\u3044\u306e\u306f\u6700\u9069\u5316\u306a\u3057\u3067\u3082\u305d\u3046\u306a\u308b\u3068\u3044\u3046\u70b9\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u76f4\u63a5\u547c\u3070\u308c\u308b\u3068\u30b7\u30f3\u30dc\u30eb\u3092\u53c2\u7167\u3059\u308b\u3088\u3046\u306b\u306a\u308b\u305f\u3081\u3001\u30ea\u30f3\u30af\u9806\u3067\u30cf\u30de\u308b\u30b1\u30fc\u30b9\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C++11 \u306b\u306f\u4eee\u60f3\u95a2\u6570\u3092\u305d\u308c\u4ee5\u4e0a\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3067\u304d\u306a\u3044\u3088\u3046\u306b\u3059\u308b final \u3068\u3044\u3046\u6307\u5b9a\u304c\u66f8\u3051\u307e\u3059\u304c\u3001final \u304c\u4ed8\u3044\u3066\u3044\u308b\u3068\u547c\u3076\u3068\u304d\u306b vtable \u3092\u53c2\u7167\u3057\u3066\u9593\u63a5call\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u76f4\u63a5\u547c\u3076\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u3068 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-6808","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6808"}],"version-history":[{"count":1,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6808\/revisions"}],"predecessor-version":[{"id":6809,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6808\/revisions\/6809"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6808"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}