{"id":248429,"date":"2015-01-28T13:57:03","date_gmt":"2015-01-28T09:57:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=248429"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=248429","title":{"rendered":"<span class=\"post_title\">\u0413\u043e\u0440\u043e\u0434\u0441\u043a\u0438\u0435 \u043b\u0435\u0433\u0435\u043d\u0434\u044b \u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430\u0445 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/span>"},"content":{"rendered":"<div class=\"content html_format\">     \t<img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/7eb\/65b\/430\/7eb65b43013a4e6fac9fbc149552ca0e.jpg\" align=\"right\"\/>\u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0432\u044b\u0437\u043e\u0432\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 \u0434\u0432\u043e\u0439\u043d\u0443\u044e \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u0443\u044e \u0430\u0434\u0440\u0435\u0441\u0430\u0446\u0438\u044e \u2014 \u0435\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u0443 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0442\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0442\u043e \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0437\u044f\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0437\u0430\u0442\u0435\u043c \u043f\u043e \u043d\u043e\u043c\u0435\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>  \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0438\u0441\u043a\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u0434\u043d\u0438\u043c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041f\u043e\u0437\u0434\u043d\u0435\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u0432\u044b\u0437\u043e\u0432, \u043d\u043e \u0438 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0441\u0430\u043c\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044e\u0449\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<p>  \u0412 \u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u044b\u0448\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u00ab\u0435\u0441\u043b\u0438\u00bb. \u0427\u0442\u043e, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0430\u0434\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c?<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 (\u0434\u0430\u043b\u0435\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442 C++03) \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043f\u0440\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432 5.2.2\/1 ([expr.call], \u00ab\u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00bb) \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u043e \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u0430\u044f \u043f\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u0438\u0437 10.3\/2 ([class.virtual], \u00ab\u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00bb), \u0430 \u0442\u0430\u043c \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e TL;DR; \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430.<\/p>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0432 \u043a\u043e\u0434, \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c \u0442\u043e\u0447\u043d\u044b\u0439 \u0442\u0438\u043f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043e\u043d \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u2013 \u0438 \u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u0443 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0438\u043b\u0438 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>  \u041e\u0442 \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0439\u2122 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043e\u0434\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430 <a href=\"http:\/\/gcc.godbolt.org\">gcc.godbolt.org<\/a><\/p>\n<p>  \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432\u043e\u0442 \u044d\u0442\u0438 \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"cpp\">class Base { public:     virtual ~Base() {}     virtual int Magic() {         return 9000;     } };  class Derived : public Base { public:     virtual int Magic() {         return 100500;     } };<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">int main() {     Derived derived;     return derived.Magic(); } <\/code><\/pre>\n<p>  clang 3.4.1 \u0441 -O2 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code>main:    # @main     movl     $100500, %eax    # imm = 0x18894     ret <\/code><\/pre>\n<p>  \u041d\u0435\u0442\u0440\u0443\u0434\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0439 \u0442\u043e\u043b\u044c\u043a\u043e <i>return 100500;<\/i> \u042d\u0442\u043e \u043d\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u2014 \u0432\u0435\u0434\u044c \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0441\u0441\u044b\u043b\u043e\u043a.<\/p>\n<p>  \u041b\u0430\u0434\u043d\u043e, \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u043f\u043e\u043c\u0435\u0448\u0438\u0432\u0430\u044f, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0438 \u0441\u0441\u044b\u043b\u043a\u0438:<\/p>\n<pre><code class=\"cpp\">int magic( Base& object ) {     return object.Magic(); }  int main() {     Base* base = new Derived();     int result = magic( *base );     delete base;     return result; }<\/code><\/pre>\n<p>  clang 3.4.1 \u0441 -O2 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code>magic(Base&):    # @magic(Base&)     movq    (%rdi), %rax     jmpq    *(%rax)    # TAILCALL  main:    # @main     movl     $100500, %eax    # imm = 0x18894     ret <\/code><\/pre>\n<p>  <s>\u041e\u0425 \u0429\u0418 \u041e\u0428\u0418\u0411\u041a\u0410 \u0412 \u041a\u041e\u041c\u041f\u0418\u041b\u042f\u0422\u041e\u0420\u0415<\/s> \u041d\u0435\u0442, \u0441 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043d\u043e \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u044c \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e. \u0421\u043d\u043e\u0432\u0430 <i>return 100500;<\/i><\/p>\n<p>  \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, gcc 4.9.0 \u0441 -O2:<\/p>\n<pre><code>main:     subq     $8, %rsp     movl     $8, %edi     call    operator new(unsigned long)     movq    vtable for Derived+16, (%rax)     movq    %rax, %rdi     call    Derived::~Derived()     movl     $100500, %eax     addq     $8, %rsp     ret <\/code><\/pre>\n<p>  <i>call Derived::~Derived()<\/i> \u2013 \u0438\u0437-\u0437\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, gcc \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0441\u0442\u0430\u0432\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 <i>::operator delete()<\/i> \u0432\u043d\u0443\u0442\u0440\u044c \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430:<\/p>\n<pre><code>Derived::~Derived():     jmp    operator delete(void*) <\/code><\/pre>\n<p>  \u0445\u043e\u0442\u044f \u043c\u043e\u0433 \u0431\u044b \u0438 \u043f\u043e \u043c\u0435\u0441\u0442\u0443 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c. \u0412\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code>    movq    %rax, %rdi     call    operator delete(void*) <\/code><\/pre>\n<p>  \u041c\u043e\u0433 \u0431\u044b, \u043d\u043e \u043d\u0435 \u0441\u0442\u0430\u043b. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0442\u0435\u043b\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <i>Derived::Magic()<\/i> \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0438\u043c \u043a\u043e\u0434\u043e\u043c.<\/p>\n<p>  \u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435\u2026 \u0415\u0441\u043b\u0438 \u0432\u044b \u043b\u044e\u0431\u0438\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0448\u0435 \u0434\u043b\u044f \u0432\u0430\u0441. \u0418 \u0432\u044b\u0437\u043e\u0432 <i>Derived::Magic()<\/i>, \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0433 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043d\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u043e\u043d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u2013 \u043d\u0435\u0442. \u041e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u043e.<\/p>\n<p>  \u0414\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, gcc 4.9.0 \u0441 -O1<\/p>\n<pre><code>magic(Base&):     subq    $8, %rsp     movq    (%rdi), %rax     call    *(%rax)     addq    $8, %rsp     ret main:     pushq   %rbp     pushq   %rbx     subq    $8, %rsp     movl    $8, %edi     call     operator new(unsigned long)     movq    %rax, %rbx     movq    vtable for Derived+16, (%rax)     movq    %rax, %rdi     call    magic(Base&)     movl    %eax, %ebp     testq    %rbx, %rbx     je    .L12     movq    (%rbx), %rax     movq    %rbx, %rdi     call    *16(%rax) .L12:     movl    %ebp, %eax     addq    $8, %rsp     popq    %rbx     popq    %rbp     ret <\/code><\/pre>\n<p>  \u0412\u043e\u0442, \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0434\u044c, \u0435\u0441\u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c. \u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435 \u00ab\u0432\u0441\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435\u00bb \u2014 \u043a\u0443\u0447\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u0432 \u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 call \u0441 \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e\u0439 \u0430\u0434\u0440\u0435\u0441\u0430\u0446\u0438\u0435\u0439 (<i>call *16(%rax)<\/i>).<\/p>\n<p>  \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0443\u0441\u043f\u0435\u0445\u0430 \u0441 -O2 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043d\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u044b\u043c\u0438 \u2013 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438, \u0430 \u044d\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p>  \u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u0441\u043f\u0435\u0448\u0438\u0442 <a href=\"https:\/\/gcc.gnu.org\/wiki\/LinkTimeOptimization\">LTO<\/a> (\u0438\u043b\u0438 \u043a\u0430\u043a \u0442\u0430\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0435\u0434\u0438\u043d\u0438\u0446 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0435).<\/p>\n<p>  \u0414\u0435\u043b\u0438\u043c \u043a\u043e\u0434 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0435\u0434\u0438\u043d\u0438\u0446 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438\u2026<\/p>\n<pre><code class=\"cpp\">\/\/Classes.h class Base { public:     virtual int Magic();     virtual ~Base(); };  class Derived : public Base { public:     virtual int Magic(); };  \/\/Classes.cpp #include &lt;Classes.h&gt; #include &lt;stdio.h&gt;  Base::~Base() { }  int Base::Magic() {     return 9000; }  int Derived::Magic() {     return 100500; }  \/\/main.cpp #include &lt;Classes.h&gt; int magic( Base& object ) {     return object.Magic(); }  int main() {     Base* base = new Derived();     int result = magic( *base );     delete base;     return result; } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0438 \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c MinGW \u0441 gcc 4.9.0<\/p>\n<pre><code>g++ -flto -g -O3 main.cpp Classes.cpp objdump -d -M intel -S --no-show-raw-insn a.exe &gt;a.txt <\/code><\/pre>\n<pre><code>int main() {     402830:\tpush   ebp     402831:\tmov    ebp,esp     402833:\tand    esp,0xfffffff0     402836:\tsub    esp,0x10     402839:\tcall   402050 &lt;___main&gt;     Base* base = new Derived();     40283e:\tmov    DWORD PTR [esp],0x4     \u0432\u044b\u0437\u043e\u0432 ::operator new()     402845:\tcall   4015d8 &lt;__Znwj&gt;     \u0437\u0430\u043f\u0438\u0441\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 vtable     40284a:\tmov    DWORD PTR [eax],0x404058     int result = magic( *base );     delete base;     402850:\tmov    ecx,eax     402852:\tcall   4015c0 &lt;__ZN7DerivedD0Ev&gt;     return result; }     \u043d\u0430 \u043c\u0435\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430      402857:\tmov    eax,0x18894     40285c:\tleave       40285d:\tret     <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f <i>mov eax, 0x18894<\/i> (100500 \u0432 \u0448\u0435\u0441\u0442\u043d\u0430\u0434\u0446\u0430\u0442\u0435\u0440\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438) \u2014 \u0441\u043d\u043e\u0432\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u044b\u0431\u0440\u0430\u043b \u043d\u0443\u0436\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u0435\u0435 \u0442\u0435\u043b\u043e \u0432 \u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<p>  \u0421\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 (Derived \u0438 Base \u0442\u0435 \u0436\u0435)\u2026  <\/p>\n<pre><code class=\"cpp\">\/\/Factory.h #include &lt;Classes.h&gt;  class Factory { public:     static Base* CreateInstance(); };  \/\/Factory.cpp #include &lt;Factory.h&gt;  Base* Factory::CreateInstance() {     return new Derived(); }  \/\/main.cpp #include &lt;Factory.h&gt;  int magic( Base& object ) {     return object.Magic(); }  int main() {     Base* base = Factory::CreateInstance();     int result = magic( *base );     delete base;     return result; } <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c, \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u0443\u0435\u043c\u2026 \u0418\u0441\u0445\u043e\u0434\u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u2122 \u2013 \u0438\u0437-\u0437\u0430 \u0430\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0435 \u0441\u0430\u043c\u044b\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0438\u0436\u0435 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u0430\u043a \u0435\u0441\u0442\u044c, \u0430 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443.  <\/p>\n<pre><code>int main() {     402830:\tpush   ebp     402831:\tmov    ebp,esp     402833:\tpush   esi     402834:\tpush   ebx     402835:\tand    esp,0xfffffff0     402838:\tsub    esp,0x10     40283b:\tcall   402050 &lt;___main&gt;     return new Derived();     402840:\tmov    DWORD PTR [esp],0x4     \u0432\u044b\u0437\u043e\u0432 ::operator new()     402847:\tcall   4015d8 &lt;__Znwj&gt;     40284c:\tmov    ebx,eax  int magic( Base& object ) {     return object.Magic();     40284e:\tmov    ecx,eax     \u0437\u0430\u043f\u0438\u0441\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 vtable     402850:\tmov    DWORD PTR [eax],0x404058     \u043f\u0440\u044f\u043c\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 Derived::Magic()     402856:\tcall   401580 &lt;__ZN7Derived5MagicEv&gt;  int main() {     delete base;     40285b:\tmov    ecx,ebx     40285d:\tmov    esi,eax     40285f:\tcall   4015b0 &lt;__ZN7DerivedD0Ev&gt;     return result;      402864:\tlea    esp,[ebp-0x8]     402867:\tmov    eax,esi     402869:\tpop    ebx     40286a:\tpop    esi     40286b:\tpop    ebp     40286c:\tret   (\u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043e) <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430  <\/p>\n<pre><code>    402856:\tcall   401580 &lt;__ZN7Derived5MagicEv&gt; <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 <i>Derived::Magic()<\/i>:  <\/p>\n<pre><code>  00401580 &lt;__ZN7Derived5MagicEv&gt;:  int Derived::Magic() {     return 100500; }     401580:\tmov    eax,0x18894     401585:\tret  <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b, \u043a\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c, \u043d\u043e \u043d\u0435 \u0441\u0442\u0430\u043b \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0430.<\/p>\n<p>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u0443\u0435\u043c \u0444\u0430\u0431\u0440\u0438\u043a\u0443 (Base \u0438 Derived \u0442\u0435 \u0436\u0435)\u2026  <\/p>\n<pre><code class=\"cpp\">\/\/Factory.h #include &lt;Classes.h&gt; enum ClassType {     BaseType,     DerivedType };  class Factory { public:     static Base* CreateInstance(ClassType classType); };  \/\/Factory.cpp #include &lt;Factory.h&gt;  Base* Factory::CreateInstance(ClassType classType) {     switch( classType ) {         case BaseType:            return new Base();         case DerivedType:            return new Derived();     } }  \/\/main.cpp #include &lt;Factory.h&gt; int magic( Base& object ) {     return object.Magic(); }  int main() {     Base* base = Factory::CreateInstance(DerivedType);     int result = magic( *base );     delete base;     return result; } <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u2026 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434, \u0447\u0442\u043e \u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0435.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c <s>party hard<\/s> \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\u2026  <\/p>\n<pre><code class=\"cpp\">#include &lt;Factory.h&gt; #include &lt;cstdlib&gt;  int magic( Base& object ) {     return object.Magic(); }  int main() {     Base* base = Factory::CreateInstance(rand() ? BaseType : DerivedType);     int result = magic( *base );     delete base;     return result; } <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u2026 (\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u044f\u0442\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e)  <\/p>\n<pre><code>int main() {     402830:\tpush   ebp     402831:\tmov    ebp,esp     402833:\tpush   esi     402834:\tpush   ebx     402835:\tand    esp,0xfffffff0     402838:\tsub    esp,0x10     40283b:\tcall   402050 &lt;___main&gt;     Base* base = Factory::CreateInstance(rand() ? BaseType : DerivedType);     \u0432\u044b\u0437\u043e\u0432 rand()      402840:\tcall   4027c8 &lt;_rand&gt;  Base* Factory::CreateInstance(ClassType classType) {     switch( classType ) {     \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438\u0437 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0432\u043c\u0435\u0441\u0442\u0435 \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 switch     402845:\ttest   eax,eax     402847:\tmov    DWORD PTR [esp],0x4     \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435     40284e:\tjne    402875 &lt;_main+0x45&gt;     \u0435\u0441\u043b\u0438 rand() \u0432\u0435\u0440\u043d\u0443\u043b\u0430 \u043d\u0435 \u043d\u043e\u043b\u044c, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0432\u043f\u0435\u0440\u0435\u0434 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441 402875     \u0435\u0441\u043b\u0438 rand() \u0432\u0435\u0440\u043d\u0443\u043b\u0430 \u043d\u043e\u043b\u044c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043d\u0435\u0442 \u0438 ...     case DerivedType:         return new Derived();     \u0432\u044b\u0437\u043e\u0432 ::operator new()       402850:\tcall   4015d8 &lt;__Znwj&gt;     \u0437\u0430\u043f\u0438\u0441\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 vtable \u043a\u043b\u0430\u0441\u0441\u0430 Derived     402855:\tmov    DWORD PTR [eax],0x404070     40285b:\tmov    ebx,eax  int magic( Base& object ) {     return object.Magic();     \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0432\u0435\u0442\u0432\u0435\u0439 -     \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043b\u0438\u0431\u043e &quot;\u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f&quot; \u0441\u044e\u0434\u0430, \u043b\u0438\u0431\u043e \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e     \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u0432\u0435\u0442\u0432\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0439\u0441\u044f \u0441 \u0430\u0434\u0440\u0435\u0441\u0430 402875 (rand() != 0)     40285d:\tmov    eax,DWORD PTR [ebx]     40285f:\tmov    ecx,ebx     \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 Magic()     402861:\tcall   DWORD PTR [eax]     402863:\tmov    esi,eax  int main() {     delete base;     402865:\tmov    eax,DWORD PTR [ebx]     402867:\tmov    ecx,ebx     \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430     402869:\tcall   DWORD PTR [eax+0x8]     return result; }     40286c:\tlea    esp,[ebp-0x8]     40286f:\tmov    eax,esi     402871:\tpop    ebx     402872:\tpop    esi     402873:\tpop    ebp     402874:\tret      Base* Factory::CreateInstance(ClassType classType) {     switch( classType ) {         case BaseType:            return new Base();     \u0441\u044e\u0434\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 40284e     \u0435\u0441\u043b\u0438 rand() != 0     \u0432\u044b\u0437\u043e\u0432 ::operator new()     402875:\tcall   4015d8 &lt;__Znwj&gt;     \u0437\u0430\u043f\u0438\u0441\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 vtable \u043a\u043b\u0430\u0441\u0441\u0430 Base     40287a:\tmov    DWORD PTR [eax],0x404058     402880:\tmov    ebx,eax     \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u0432\u0435\u0442\u0432\u0438 \u0438 \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0432 \u0442\u043e\u0447\u043a\u0443 \u0441\u043b\u0438\u044f\u043d\u0438\u044f     402882:\tjmp    40285d &lt;_main+0x2d&gt; <\/code><\/pre>\n<p>  \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 \u0444\u0430\u0431\u0440\u0438\u043a\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043f\u043e \u043c\u0435\u0441\u0442\u0443. \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>rand()<\/i> \u043f\u0440\u044f\u043c\u043e \u0432\u043d\u0443\u0442\u0440\u0438 <i>main()<\/i> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0433 \u0431\u044b \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438 \u043f\u0440\u044f\u043c\u044b\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0432\u0435\u0442\u0432\u0435\u0439, \u043d\u043e \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438 \u0441\u043a\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u0434\u0432\u0430 \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u0430 \u2013 \u043e\u0434\u0438\u043d \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <i>Magic()<\/i> \u0441 \u043f\u043e\u0437\u0434\u043d\u0438\u043c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435\u043c, \u0432\u0442\u043e\u0440\u043e\u0439 \u2013 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0442\u043e\u0436\u0435 \u0441 \u043f\u043e\u0437\u0434\u043d\u0438\u043c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435\u043c.<\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0432\u044b\u0437\u043e\u0432\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0435 \u043e\u0431\u044f\u0437\u044b\u0432\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435, \u0430 \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u2013 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430, \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>  <i>\u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u041c\u0435\u0449\u0435\u0440\u044f\u043a\u043e\u0432,<br \/>  \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432<\/i>      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/company\/abbyy\/blog\/248429\/\"> http:\/\/habrahabr.ru\/company\/abbyy\/blog\/248429\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">     \t<img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/7eb\/65b\/430\/7eb65b43013a4e6fac9fbc149552ca0e.jpg\" align=\"right\"\/>\u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0432\u044b\u0437\u043e\u0432\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 \u0434\u0432\u043e\u0439\u043d\u0443\u044e \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u0443\u044e \u0430\u0434\u0440\u0435\u0441\u0430\u0446\u0438\u044e \u2014 \u0435\u0441\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u043d\u0443 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0442\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0442\u043e \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0437\u044f\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0437\u0430\u0442\u0435\u043c \u043f\u043e \u043d\u043e\u043c\u0435\u0440\u0443 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u0434\u0440\u0435\u0441, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<p>  \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0438\u0441\u043a\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044e \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u0434\u043d\u0438\u043c \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435\u043c \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041f\u043e\u0437\u0434\u043d\u0435\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u0432\u044b\u0437\u043e\u0432, \u043d\u043e \u0438 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u0441\u0430\u043c\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044e\u0449\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<p>  \u0412 \u0442\u0435\u043a\u0441\u0442\u0435 \u0432\u044b\u0448\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u00ab\u0435\u0441\u043b\u0438\u00bb. \u0427\u0442\u043e, \u0435\u0441\u043b\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0430\u0434\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c?  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-248429","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/248429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=248429"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/248429\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=248429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=248429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=248429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}