{"id":303743,"date":"2020-05-17T15:00:29","date_gmt":"2020-05-17T15:00:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=303743"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=303743","title":{"rendered":"\u0418\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/499020\/\">\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0435\u0433\u043e \u0432 c++ \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u043d\u0435-void \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u0432\u044b\u0437\u043e\u0432\u0430 return \u0441 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c. \u0421\u0442\u0430\u0442\u044c\u044f \u043d\u043e\u0441\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u0443\u0447\u043d\u043e-\u0440\u0430\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440, \u0447\u0435\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439.<br \/>  \u041a\u043e\u043c\u0443 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0432\u0435\u0441\u0435\u043b\u043e \u0441\u043a\u0430\u043a\u0430\u0442\u044c \u043f\u043e \u0433\u0440\u0430\u0431\u043b\u044f\u043c \u2014 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043c\u043e, \u043d\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u0441\u044f.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0412\u0441\u0435\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 c++-\u043a\u043e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<br \/>  \u041e\u0434\u043d\u0430\u043a\u043e:<br \/>   \u2014 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0430\u0441\u043d\u044b\u043c \u0438\u0437-\u0437\u0430 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0439;<br \/>   \u2014 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0433\u0434\u0435 \u0433\u0440\u0430\u043d\u044c.<\/p>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0435\u0433\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u0432 \u043d\u0435-void \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 return.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430\u043c\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0440\u0435\u0436\u0438\u043c\u0430\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>  \u0418\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434 Linux \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/www.godbolt.org\/\" rel=\"nofollow\">Compiler Explorer<\/a>. \u0418\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434 Windows \u0438 macOs X \u2014 \u043d\u0430 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c \u043c\u043d\u0435 \u0436\u0435\u043b\u0435\u0437\u0435.<\/p>\n<p>  \u0412\u0441\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f x86-x64.<br \/>  \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043c\u0435\u0440 \u0434\u043b\u044f \u0443\u0441\u0438\u043b\u0435\u043d\u0438\u044f \u043b\u0438\u0431\u043e \u043f\u043e\u0434\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439\/\u043e\u0448\u0438\u0431\u043e\u043a \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>  \u0411\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0415\u0433\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u0435, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0440\u0430\u0437\u043d\u043e\u0448\u0451\u0440\u0441\u0442\u043d\u043e\u0435, \u0442.\u043a. \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (\u0445\u043e\u0440\u043e\u0448\u043e \u0445\u043e\u0442\u044c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0432\u0435\u0437\u0434\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 Intel). \u041a \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u044f \u0431\u0443\u0434\u0443 \u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043c\u0435\u0440\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u043d\u0430\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0435\u043a\u0430.<\/p>\n<h3>\u0427\u0438\u0442\u0430\u0435\u043c \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442<\/h3>\n<p>  C++11 final draft n3797, C++14 final draft N3936:  <\/p>\n<blockquote><p>6.6.3 The return statement<br \/>  \u2026<br \/>  Flowing off the end of a function is equivalent to a return with no value; this results in undefined<br \/>  behavior in a value-returning function.<br \/>  \u2026  <\/p><\/blockquote>\n<p>  <\/p>\n<blockquote><p>\u0414\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0446\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044e return \u0431\u0435\u0437 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f; \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e, \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044e.  <\/p><\/blockquote>\n<p>  C++17 draft n4713  <\/p>\n<blockquote><p>9.6.3 The return statement<br \/>  \u2026<br \/>  Flowing off the end of a constructor, a destructor, or a function with a cv void return type is equivalent to a return with no operand. Otherwise, flowing off the end of a function other than main (6.8.3.1) results in undefined behavior.<br \/>  \u2026  <\/p><\/blockquote>\n<p>  <\/p>\n<blockquote><p>\u0414\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0446\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c void (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0441 \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438 const \u0438 volatile) \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044e return \u0431\u0435\u0437 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0432\u0441\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044e (\u043a\u0440\u043e\u043c\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main).  <\/p><\/blockquote>\n<p>  <b>\u0427\u0442\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435?<\/b><br \/>  \u0415\u0441\u043b\u0438 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<br \/>   \u2014 \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c return \u0441 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430;<br \/>   \u2014 \u0438\u043d\u0430\u0447\u0435 \u2014 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435;<br \/>   \u2014 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0435 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043d\u0435 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043d\u0435\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0435\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438;<br \/>   \u2014 \u0435\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u0430\u043a \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0435, \u0442\u0430\u043a \u0438 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0435 \u043f\u0443\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u2014 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u043f\u0443\u0442\u044f\u0445;<br \/>   \u2014 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445\u0441\u044f \u0432 \u0442\u0435\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u0424\u0440\u0430\u0437\u0430 \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e main \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u0448\u0435\u0441\u0442\u0432\u043e\u043c c++17 \u2014 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 3.6.1 Main function.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 1 \u2014 bool<\/h3>\n<p>  \u0412 c++ \u043d\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u0447\u0435\u043c bool. \u0412\u043e\u0442 \u0441 \u043d\u0435\u0433\u043e \u0438 \u043d\u0430\u0447\u043d\u0451\u043c.<\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt;  bool bad() {};  int main() {     std::cout &lt;&lt; bad();      return 0; } <\/code><\/pre>\n<p>  MSVC \u0432\u044b\u0434\u0430\u0451\u0442 \u043d\u0430 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0448\u0438\u0431\u043a\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 C4716, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f MSVC \u043a\u043e\u0434 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u043b\u0435\u0433\u043a\u0430 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u0442\u044c, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:  <\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;stdlib.h&gt;  bool bad() {     if (rand() == 0) {         return true;     } }  int main() {     std::cout &lt;&lt; bad();      return 0; } <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f:  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<th>\u041f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430<\/th>\n<th>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440<\/th>\n<th>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/th>\n<\/tr>\n<tr>\n<td>Linux<\/td>\n<td>x86-x64 Clang 10.0.0<\/td>\n<td>warning: non-void function does not return a value [-Wreturn-type]<\/td>\n<\/tr>\n<tr>\n<td>Linux<\/td>\n<td>x86-x64 gcc 9.3<\/td>\n<td>warning: no return statement in function returning non-void [-Wreturn-type]<\/td>\n<\/tr>\n<tr>\n<td>macOs X<\/td>\n<td>Apple clang version 11.0.0<\/td>\n<td>warning: control reaches end of non-void function [-Wreturn-type]<\/td>\n<\/tr>\n<tr>\n<td>Windows<\/td>\n<td>MSVC 2019 16.5.4<\/td>\n<td>\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 error C4716, \u0443\u0441\u043b\u043e\u0436\u043d\u0451\u043d\u043d\u044b\u0439 \u2014 warning C4715: not all control paths return a value<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><b>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/td>\n<td><b>Program return<\/b><\/td>\n<td><b>Console output<\/b><\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\"><b>Linux x86-x64 Clang 10.0.0<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>255<\/td>\n<td>No output<\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2<\/td>\n<td>0<\/td>\n<td>No output<\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\"><b>Linux x86-x64 gcc 9.3<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>0<\/td>\n<td>89<\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2, -O3<\/td>\n<td>0<\/td>\n<td>No output<\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\"><b>macOs X Apple clang version 11.0.0<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0, -O1, -O2<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\"><b>Windows MSVC 2019 16.5.4, \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/b><\/td>\n<\/tr>\n<tr>\n<td>\/Od, \/O1, \/O2<\/td>\n<td>No build<\/td>\n<td>No build<\/td>\n<\/tr>\n<tr>\n<td colspan=\"3\"><b>Windows MSVC 2019 16.5.4, \u0443\u0441\u043b\u043e\u0436\u043d\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/b><\/td>\n<\/tr>\n<tr>\n<td>\/Od<\/td>\n<td>0<\/td>\n<td>41<\/td>\n<\/tr>\n<tr>\n<td>\/O1, \/O2<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u0414\u0430\u0436\u0435 \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0442\u0440\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<br \/>  \u0418\u0434\u0451\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0436\u0435 \u0442\u0430\u043c \u044d\u0442\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u043d\u0430\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0438.<\/p>\n<h4>Linux x86-x64 Clang 10.0.0, -O0<\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yc\/pg\/vw\/ycpgvw4062ruxbxhec61lpr5oec.png\" alt=\"image\"><br \/>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u2014 <b>ud2<\/b>.<br \/>  \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0438\u0437 <b>Intel 64 and IA-32 Architectures Software Developer\u2019s Manual<\/b>:  <\/p>\n<blockquote><p>UD2\u2014Undefined Instruction<br \/>  Generates an invalid opcode exception. This instruction is provided for software testing to explicitly generate an invalid opcode exception. The opcode for this instruction is reserved for this purpose.<br \/>  Other than raising the invalid opcode exception, this instruction has no effect on processor state or memory.<br \/>  Even though it is the execution of the UD2 instruction that causes the invalid opcode exception, the instruction pointer saved by delivery of the exception references the UD2 instruction (and not the following instruction).<br \/>  This instruction\u2019s operation is the same in non-64-bit modes and 64-bit mode.  <\/p><\/blockquote>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e \u2014 \u044d\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <b>\u041d\u0430\u0434\u043e \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u044b\u0437\u043e\u0432 bad() \u0432 \u0431\u043b\u043e\u043a try\u2026 catch !?<\/b><br \/>  \u041a\u0430\u043a \u0431\u044b \u043d\u0435 \u0442\u0430\u043a. \u042d\u0442\u043e \u043d\u0435 c++-\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <b>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u043e\u0442\u043b\u043e\u0432\u0438\u0442\u044c ud2 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435?<\/b><br \/>  \u041f\u043e\u0434 Windows \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c __try, \u043f\u043e\u0434 Linux \u0438 macOs X \u2014 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u0438\u0433\u043d\u0430\u043b\u0430 SIGILL.<\/p>\n<h4>Linux x86-x64 Clang 10.0.0, -O1, -O2<\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qg\/al\/gl\/qgalgl3q6xaqajpp2kdjqxpbp9m.png\" alt=\"image\"><br \/>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u043b \u0438 \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u043b \u043a\u0430\u043a \u0442\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad(), \u0442\u0430\u043a \u0438 \u0435\u0451 \u0432\u044b\u0437\u043e\u0432.<\/p>\n<h4>Linux x86-x64 gcc 9.3, -O0<\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/a7\/ny\/2g\/a7ny2ghbcx-bj4a73pqzu_y_eam.png\" alt=\"image\"><br \/>  \u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f (\u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0442.\u043a. \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043f\u0440\u043e\u0449\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0446\u0430):<br \/>  5. \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 stream \u0434\u043b\u044f bool (\u0441\u0442\u0440\u043e\u043a\u0430 14);<br \/>  4. \u0412 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 edi \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 std::cout \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 stream (\u0441\u0442\u0440\u043e\u043a\u0430 13);<br \/>  3. \u0412 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 esi \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 eax \u2014 \u044d\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 stream (\u0441\u0442\u0440\u043e\u043a\u0430 12);<br \/>  2. \u041e\u0431\u043d\u0443\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u0440\u0438 \u0441\u0442\u0430\u0440\u0448\u0438\u0445 \u0431\u0430\u0439\u0442\u0430 eax, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 al \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f (\u0441\u0442\u0440\u043e\u043a\u0430 11);<br \/>  1. \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f bad() (\u0441\u0442\u0440\u043e\u043a\u0430 10);<br \/>  0. \u0424\u0443\u043d\u043a\u0446\u0438\u044f bad() \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 al.<br \/>  \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 4 \u2014 nop (No Operation, \u043f\u0443\u0441\u0442\u044b\u0448\u043a\u0430).<br \/>  \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 al. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0448\u0442\u0430\u0442\u043d\u043e.<\/p>\n<h4>Linux x86-x64 gcc 9.3, -O1, -O2, -O3<\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dp\/sl\/yh\/dpslyhnvjwxt2c24ifgw6lgpxnu.png\" alt=\"image\"><br \/>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u0441\u0451 \u043f\u043e\u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<h4>macOs X Apple clang version 11.0.0, -O0<\/h4>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f main():<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ey\/kl\/aw\/eyklawd5cgswoa14yg-h8iotxkq.png\" alt=\"image\"><br \/>  \u041f\u0443\u0442\u044c \u0431\u0443\u043b\u0435\u0432\u0441\u043a\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u043f\u043e\u0442\u043e\u043a (\u043d\u0430 \u0441\u0435\u0439 \u0440\u0430\u0437 \u0432 \u043f\u0440\u044f\u043c\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435):<br \/>  1. \u0412 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 edx \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 al (\u0441\u0442\u0440\u043e\u043a\u0430 8);<br \/>  2. \u0417\u0430\u043d\u0443\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0431\u0438\u0442\u044b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 edx, \u043a\u0440\u043e\u043c\u0435 \u043c\u043b\u0430\u0434\u0448\u0435\u0433\u043e (\u0441\u0442\u0440\u043e\u043a\u0430 9);<br \/>  3. \u0412 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 rdi \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 std::cout \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 stream (\u0441\u0442\u0440\u043e\u043a\u0430 10);<br \/>  4. \u0412 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 esi \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 edx \u2014 \u044d\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 stream (\u0441\u0442\u0440\u043e\u043a\u0430 11);<br \/>  5. \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 stream \u0434\u043b\u044f bool (\u0441\u0442\u0440\u043e\u043a\u0430 13);<br \/>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f main \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 al.<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f bad():<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/v5\/tx\/1p\/v5tx1pohulp-fewcheimnj0wnkk.png\" alt=\"image\"><br \/>  1. \u0412 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 al \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e, \u0435\u0449\u0451 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e, \u0431\u0430\u0439\u0442\u0430 \u0441\u0442\u0435\u043a\u0430 (\u0441\u0442\u0440\u043e\u043a\u0430 4);<br \/>  2. \u0417\u0430\u043d\u0443\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0431\u0438\u0442\u044b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 al, \u043a\u0440\u043e\u043c\u0435 \u043c\u043b\u0430\u0434\u0448\u0435\u0433\u043e (\u0441\u0442\u0440\u043e\u043a\u0430 5);<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0431\u0438\u0442 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438\u0437 \u043d\u0435\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430. \u0422\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0430\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u043e\u043b\u044c.<br \/>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0448\u0442\u0430\u0442\u043d\u043e.<\/p>\n<h4>macOs X Apple clang version 11.0.0, -O1, -O2<\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zh\/mm\/t0\/zhmmt0z4yvmtiunqa287sdu9lky.png\" alt=\"image\"><br \/>  \u0411\u0443\u043b\u0435\u0432\u0441\u043a\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 stream \u043e\u0431\u043d\u0443\u043b\u044f\u0435\u0442\u0441\u044f (\u0441\u0442\u0440\u043e\u043a\u0430 5).<br \/>  \u0412\u044b\u0437\u043e\u0432 bad() \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d \u043f\u0440\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<br \/>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043d\u043e\u043b\u044c \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0448\u0442\u0430\u0442\u043d\u043e.<\/p>\n<h4>Windows MSVC 2019 16.5.4, \u0443\u0441\u043b\u043e\u0436\u043d\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \/Od<\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/pb\/iz\/ku\/pbizkuhiff8y37zk6i2ea1qrwb8.png\" alt=\"image\"><br \/>  \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f bad() \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 al.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/au\/ej\/zn\/auejznebzsjq0n_e4kgtbkfd5ae.png\" alt=\"image\"><br \/>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d\u043d\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 bad(), \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430 \u0441\u0442\u0435\u043a, \u0430 \u043f\u043e\u0442\u043e\u043c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 edx \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 stream.<br \/>  \u0412 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 al (\u0435\u0441\u043b\u0438 \u0447\u0443\u0442\u044c \u0442\u043e\u0447\u043d\u0435\u0435 \u2014 \u0442\u043e \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0430\u0439\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 rand()). \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0448\u0442\u0430\u0442\u043d\u043e.<\/p>\n<h4>Windows MSVC 2019 16.5.4, \u0443\u0441\u043b\u043e\u0436\u043d\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \/O1, \/O2<\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/mk\/wr\/jy\/mkwrjyimc1tfaqfzq_hzuorcaba.png\" alt=\"image\"><br \/>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0438\u043d\u043b\u0430\u0439\u043d\u0438\u043b \u0432\u044b\u0437\u043e\u0432 bad(). \u0424\u0443\u043d\u043a\u0446\u0438\u044f main():<br \/>   \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 rand() (\u0441\u0442\u0440\u043e\u043a\u0430 8);<br \/>   \u2014 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d\u043d\u043e\u0433\u043e rand(), \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 ecx (\u0441\u0442\u0440\u043e\u043a\u0430 10);<br \/>   \u2014 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 ebx (\u0441\u0442\u0440\u043e\u043a\u0430 11);<br \/>   \u2014 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 dl (\u0442\u043e\u0447\u043d\u0435\u0435, \u0435\u0433\u043e \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0430\u0439\u0442) (\u0441\u0442\u0440\u043e\u043a\u0430 13);<br \/>   \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 stream, \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u0432\u044b\u0432\u043e\u0434 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f dl (\u0441\u0442\u0440\u043e\u043a\u0430 14).<br \/>  \u0412 stream \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u0430.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434 \u043f\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0443 1<\/h3>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><b>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/td>\n<td><b>Program return<\/b><\/td>\n<td><b>Console output<\/b><\/td>\n<td><b>\u041f\u0440\u0438\u0447\u0438\u043d\u0430<\/b><\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Linux x86-x64 Clang 10.0.0<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>255<\/td>\n<td>No output<\/td>\n<td>ud2<\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2<\/td>\n<td>0<\/td>\n<td>No output<\/td>\n<td>\u0412\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Linux x86-x64 gcc 9.3<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>0<\/td>\n<td>89<\/td>\n<td>\u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 al<\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2, -O3<\/td>\n<td>0<\/td>\n<td>No output<\/td>\n<td>\u0412\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>macOs X Apple clang version 11.0.0<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>\u041e\u0434\u0438\u043d \u0431\u0438\u0442 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438<\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u0437\u0430\u043c\u0435\u043d\u0451\u043d \u043d\u0443\u043b\u0451\u043c<\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Windows MSVC 2019 16.5.4, \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/b><\/td>\n<\/tr>\n<tr>\n<td>\/Od, \/O1, \/O2<\/td>\n<td>No build<\/td>\n<td>No build<\/td>\n<td>No build<\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Windows MSVC 2019 16.5.4, \u0443\u0441\u043b\u043e\u0436\u043d\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/b><\/td>\n<\/tr>\n<tr>\n<td>\/Od<\/td>\n<td>0<\/td>\n<td>41<\/td>\n<td>\u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 al<\/td>\n<\/tr>\n<tr>\n<td>\/O1, \/O2<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u0437\u0430\u043c\u0435\u043d\u0451\u043d \u0435\u0434\u0438\u043d\u0438\u0446\u0435\u0439<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u0435 3, \u0430 \u0446\u0435\u043b\u044b\u0445 6 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044f \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 \u043c\u044b \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 1a \u2014 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c<\/h3>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0443\u043b\u0438\u0442\u044c \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u2014 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 bad().<br \/>  \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u0435\u043c\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0432\u043e\u0434\u044f\u0442 \u043c\u0443\u0441\u043e\u0440.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0442\u0435 \u043c\u0435\u0441\u0442\u0430, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u0438\u0445 \u0431\u0443\u0434\u0443\u0442 \u0431\u0440\u0430\u0442\u044c.<\/p>\n<h4>Linux x86-x64 gcc 9.3, -O0<\/h4>\n<p>  \u041f\u0443\u0441\u0442\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f bad() \u043d\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 al, \u043a\u0430\u043a \u043e\u0442 \u043d\u0435\u0451 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0432 al \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 bad(), \u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f bad().<br \/>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430 \u043b\u044e\u0431\u043e\u0439 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0439 bool. \u041d\u043e \u0442\u0430\u043a\u0436\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, unsinged char.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;iostream&gt;  bool bad() {}  bool goodTrue() {     return rand(); }  bool goodFalse() {     return !goodTrue(); }  unsigned char goodChar(unsigned char ch) {     return ch; }  int main() {     goodTrue();     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      goodChar(85);     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      goodFalse();     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      goodChar(240);     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:  <\/p>\n<blockquote><p>1<br \/>  85<br \/>  0<br \/>  240  <\/p><\/blockquote>\n<h4>Windows MSVC 2019 16.5.4, \/Od<\/h4>\n<p>  \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u043b\u044f MSVC \u0444\u0443\u043d\u043a\u0446\u0438\u044f bad() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0430\u0439\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 rand().<br \/>  \u0411\u0435\u0437 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0435\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438\u0437\u043c\u0435\u043d\u044f\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 rand().  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;stdlib.h&gt;  void control(unsigned char value) {     uint32_t count = 0;     srand(0);     while ((rand() &amp; 0xff) != value) {         ++count;     }      srand(0);     for (uint32_t i = 0; i &lt; count; ++i) {         rand();     } }  bool bad() {     if (rand() == 0) {         return true;     } }  int main() {     control(1);     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      control(85);     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      control(0);     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      control(240);     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:  <\/p>\n<blockquote><p>1<br \/>  85<br \/>  0<br \/>  240  <\/p><\/blockquote>\n<h4>macOs X Apple clang version 11.0.0, -O0<\/h4>\n<p>  \u041d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c bad() \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0442\u0443 \u044f\u0447\u0435\u0439\u043a\u0443 \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u043c\u043b\u0430\u0434\u0448\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0441\u0442\u0435\u043a\u0430 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 bad().  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;iostream&gt;  bool bad() {}  void putToStack(uint8_t value) {     uint8_t memory[1]{value}; }  int main() {     putToStack(20);     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      putToStack(55);     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      putToStack(0xfe);     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      putToStack(11);     std::cout &lt;&lt; bad() &lt;&lt; std::endl;      return 0; } <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 -O0, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f \u043e \u0441\u043e\u0445\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 memory. \u041e\u043d\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u0430 \u043f\u0440\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<br \/>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f memory \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u2014 \u0438\u043d\u0430\u0447\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0435\u0451 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430, \u0430 \u043d\u0435 \u043d\u0430 \u0441\u0442\u0435\u043a, \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0430\u0434\u043e.<br \/>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c, \u0442.\u043a. \u0432\u043e\u043e\u0431\u0449\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u2014 \u0442\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f putToStack \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043c\u0430\u0445\u0438\u0432\u0430\u0442\u044c\u0441\u044f.  <\/div>\n<\/p><\/div>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:  <\/p>\n<blockquote><p>0<br \/>  1<br \/>  0<br \/>  1  <\/p><\/blockquote>\n<p>  \u0412\u0440\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c: \u0443\u0434\u0430\u0451\u0442\u0441\u044f \u043c\u0435\u043d\u044f\u0442\u044c \u0432\u044b\u0434\u0430\u0447\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad(), \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0438\u0442.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434 \u043f\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0443 1a<\/h3>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0442\u0440\u0430\u043a\u0442\u043e\u0432\u043a\u0438 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 1b \u2014 \u0441\u043b\u043e\u043c\u0430\u043d\u043d\u044b\u0439 bool<\/h3>\n<p>  <b>\u041d\u0443 \u043f\u043e\u0434\u0443\u0443\u0443\u0443\u0443\u043c\u0430\u0435\u0448\u044c, \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u0435\u0434\u0435\u0442\u0441\u044f \u00ab41\u00bb \u0432\u043c\u0435\u0441\u0442\u043e \u00ab1\u00bb\u2026 \u0420\u0430\u0437\u0432\u0435 \u044d\u0442\u043e \u043e\u043f\u0430\u0441\u043d\u043e?<\/b><br \/>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u043d\u0430 \u0434\u0432\u0443\u0445 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430\u0445, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0432\u0448\u0438\u0445 \u0446\u0435\u043b\u044b\u0439 \u0431\u0430\u0439\u0442 \u043c\u0443\u0441\u043e\u0440\u0430.<\/p>\n<h4>Windows MSVC 2019 16.5.4, \/Od<\/h4>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;stdlib.h&gt; #include &lt;set&gt; #include &lt;unordered_set&gt;  bool bad() {     if (rand() == 0) {         return true;     } }  int main() {     bool badBool1 = bad();     bool badBool2 = bad();      std::cout &lt;&lt; &quot;badBool1: &quot; &lt;&lt; badBool1 &lt;&lt; std::endl;     std::cout &lt;&lt; &quot;badBool2: &quot; &lt;&lt; badBool2 &lt;&lt; std::endl;      if (badBool1) {       std::cout &lt;&lt; &quot;if (badBool1): true&quot; &lt;&lt; std::endl;     } else {       std::cout &lt;&lt; &quot;if (badBool1): false&quot; &lt;&lt; std::endl;     }     if (!badBool1) {       std::cout &lt;&lt; &quot;if (!badBool1): true&quot; &lt;&lt; std::endl;     } else {       std::cout &lt;&lt; &quot;if (!badBool1): false&quot; &lt;&lt; std::endl;     }      std::cout &lt;&lt; &quot;(badBool1 == true || badBool1 == false || badBool1 == badBool2): &quot;               &lt;&lt; std::boolalpha &lt;&lt; (badBool1 == true || badBool1 == false || badBool1 == badBool2)               &lt;&lt; std::endl;     std::cout &lt;&lt; &quot;std::set&lt;bool&gt;{badBool1, badBool2, true, false}.size(): &quot;               &lt;&lt; std::set&lt;bool&gt;{badBool1, badBool2, true, false}.size()               &lt;&lt; std::endl;     std::cout &lt;&lt; &quot;std::unordered_set&lt;bool&gt;{badBool1, badBool2, true, false}.size(): &quot;               &lt;&lt; std::unordered_set&lt;bool&gt;{badBool1, badBool2, true, false}.size()               &lt;&lt; std::endl;      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:  <\/p>\n<blockquote><p>badBool1: 41<br \/>  badBool2: 35<br \/>  if (badBool1): true<br \/>  if (!badBool1): false<br \/>  (badBool1 == true || badBool1 == false || badBool1 == badBool2): <b>false<\/b><br \/>  std::set&lt;bool&gt;{badBool1, badBool2, true, false}.size(): <b>4<\/b><br \/>  std::unordered_set&lt;bool&gt;{badBool1, badBool2, true, false}.size(): <b>4<\/b>  <\/p><\/blockquote>\n<p>  \u041d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u043a \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044e \u0431\u0443\u043b\u0435\u0432\u0441\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043b\u043e\u043c\u0430\u0435\u0442 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c:<br \/>   \u2014 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u043b\u0435\u0432\u0441\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439;<br \/>   \u2014 \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0431\u0443\u043b\u0435\u0432\u0441\u043a\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<h4>Linux x86-x64 gcc 9.3, -O0<\/h4>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;stdlib.h&gt; #include &lt;set&gt; #include &lt;unordered_set&gt;  bool bad() { }  unsigned char goodChar(unsigned char ch) {   return ch; }  int main() {   goodChar(213);   bool badBool1 = bad();    goodChar(137);   bool badBool2 = bad();    std::cout &lt;&lt; &quot;badBool1: &quot; &lt;&lt; badBool1 &lt;&lt; std::endl;   std::cout &lt;&lt; &quot;badBool2: &quot; &lt;&lt; badBool2 &lt;&lt; std::endl;    if (badBool1) {     std::cout &lt;&lt; &quot;if (badBool1): true&quot; &lt;&lt; std::endl;   }   else {     std::cout &lt;&lt; &quot;if (badBool1): false&quot; &lt;&lt; std::endl;   }   if (!badBool1) {     std::cout &lt;&lt; &quot;if (!badBool1): true&quot; &lt;&lt; std::endl;   }   else {     std::cout &lt;&lt; &quot;if (!badBool1): false&quot; &lt;&lt; std::endl;   }    std::cout &lt;&lt; &quot;(badBool1 == true || badBool1 == false || badBool1 == badBool2): &quot;     &lt;&lt; std::boolalpha &lt;&lt; (badBool1 == true || badBool1 == false || badBool1 == badBool2)     &lt;&lt; std::endl;   std::cout &lt;&lt; &quot;std::set&lt;bool&gt;{badBool1, badBool2, true, false}.size(): &quot;     &lt;&lt; std::set&lt;bool&gt;{badBool1, badBool2, true, false}.size()     &lt;&lt; std::endl;   std::cout &lt;&lt; &quot;std::unordered_set&lt;bool&gt;{badBool1, badBool2, true, false}.size(): &quot;     &lt;&lt; std::unordered_set&lt;bool&gt;{badBool1, badBool2, true, false}.size()     &lt;&lt; std::endl;    return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:  <\/p>\n<blockquote><p>badBool1: 213<br \/>  badBool2: 137<br \/>  if (badBool1): true<br \/>  if (!badBool1): <b>true<\/b><br \/>  (badBool1 == true || badBool1 == false || badBool1 == badBool2): <b>false<\/b><br \/>  std::set&lt;bool&gt;{badBool1, badBool2, true, false}.size(): <b>4<\/b><br \/>  std::unordered_set&lt;bool&gt;{badBool1, badBool2, true, false}.size(): <b>4<br \/>  <\/b>  <\/p><\/blockquote>\n<p>  \u041f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 MSVC, \u0432 gcc \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0435\u0449\u0451 \u0438 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 not.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434 \u043f\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0443 1b<\/h3>\n<p>  \u041d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u0431\u0443\u043b\u0435\u0432\u0441\u043a\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<p>  <b>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e?<\/b><br \/>  \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u0431\u0443\u043b\u0435\u0432\u0441\u043a\u0438\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0447\u0442\u043e true \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u0433\u043e \u0435\u0434\u0438\u043d\u0438\u0446\u0430.<br \/>  \u0412 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u2014 \u0441\u0442\u0430\u0442\u044c\u044f \u0438 \u0442\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043e\u0431\u044a\u0451\u043c\u043d\u043e\u0439.<\/p>\n<p>  \u0412 \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0440\u0430\u0437 \u0443\u0442\u043e\u0447\u043d\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432:  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><b>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/td>\n<td><b>Program return<\/b><\/td>\n<td><b>Console output<\/b><\/td>\n<td><b>\u041f\u0440\u0438\u0447\u0438\u043d\u0430<\/b><\/td>\n<td><b>\u041f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 bad()<\/b><\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Linux x86-x64 Clang 10.0.0<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>255<\/td>\n<td>No output<\/td>\n<td>ud2<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2<\/td>\n<td>0<\/td>\n<td>No output<\/td>\n<td>\u0412\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Linux x86-x64 gcc 9.3<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>0<\/td>\n<td>89<\/td>\n<td>\u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 al<\/td>\n<td>\u041d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b:<br \/>  not; ==; !=; &lt;; &gt;; &lt;=; &gt;=; std::hash.  <\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2, -O3<\/td>\n<td>0<\/td>\n<td>No output<\/td>\n<td>\u0412\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u044b \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>macOs X Apple clang version 11.0.0<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>\u041e\u0434\u0438\u043d \u0431\u0438\u0442 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2<\/td>\n<td>0<\/td>\n<td>0<\/td>\n<td>\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u0437\u0430\u043c\u0435\u043d\u0451\u043d \u043d\u0443\u043b\u0451\u043c<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Windows MSVC 2019 16.5.4, \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/b><\/td>\n<\/tr>\n<tr>\n<td>\/Od, \/O1, \/O2<\/td>\n<td>No build<\/td>\n<td>No build<\/td>\n<td>No build<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Windows MSVC 2019 16.5.4, \u0443\u0441\u043b\u043e\u0436\u043d\u0451\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/b><\/td>\n<\/tr>\n<tr>\n<td>\/Od<\/td>\n<td>0<\/td>\n<td>41<\/td>\n<td>\u041e\u0434\u0438\u043d \u0431\u0430\u0439\u0442 \u043c\u0443\u0441\u043e\u0440\u0430 \u0438\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 al<\/td>\n<td>\u041d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b:<br \/>  ==; !=; &lt;; &gt;; &lt;=; &gt;=; std::hash.<\/td>\n<\/tr>\n<tr>\n<td>\/O1, \/O2<\/td>\n<td>0<\/td>\n<td>1<\/td>\n<td>\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad() \u0437\u0430\u043c\u0435\u043d\u0451\u043d \u0435\u0434\u0438\u043d\u0438\u0446\u0435\u0439<\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u0427\u0435\u0442\u044b\u0440\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0434\u0430\u043b\u0438 7 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 2 \u2014 struct<\/h3>\n<p>  \u0412\u043e\u0437\u044c\u043c\u0451\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0443\u0442\u044c \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435:  <\/p>\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;stdlib.h&gt;  struct Test {     Test(uint64_t v)         : value(v)     {         std::cout &lt;&lt; &quot;Test::Test(&quot; &lt;&lt; v &lt;&lt; &quot;)&quot; &lt;&lt; std::endl;     }     ~Test()     {         std::cout &lt;&lt; &quot;Test::~Test()&quot; &lt;&lt; std::endl;     }      uint64_t value; };  Test bad(int v) {     if (v == 0) {         return {42};     } else if (v == 1) {         return {142};     } }  int main() {     const auto rnd = rand();     std::cout &lt;&lt; &quot;rnd: &quot; &lt;&lt; rnd &lt;&lt; std::endl;      std::cout &lt;&lt; bad(rnd).value &lt;&lt; std::endl;      return 0; } <\/code><\/pre>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 Test \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430 int. \u0418\u0437 \u0435\u0451 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u0432\u043e\u0434 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0424\u0443\u043d\u043a\u0446\u0438\u044f bad(int) \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u043f\u0443\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043d\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043f\u0440\u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435.<br \/>  \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u2014 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u043f\u043e\u0442\u043e\u043c \u0440\u0430\u0437\u0431\u043e\u0440 \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0430 \u043f\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0443\u043d\u043a\u0442\u0430\u043c.  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<tr>\n<td><b>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/td>\n<td><b>Program return<\/b><\/td>\n<td><b>Console output<\/b><\/td>\n<td><b>\u041f\u0440\u0438\u0447\u0438\u043d\u0430<\/b><\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Linux x86-x64 Clang 10.0.0<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>255<\/td>\n<td>rnd: 1804289383<\/td>\n<td>ud2<\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2<\/td>\n<td>0<\/td>\n<td>rnd: 1804289383<br \/>  Test::Test(142)<br \/>  142<br \/>  Test::~Test()<\/td>\n<td>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 if (v == 1) \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f. \u0411\u043b\u043e\u043a else if \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u043e else.<\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Linux x86-x64 gcc 9.3<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>0<\/td>\n<td>rnd: 1804289383<br \/>  4198608<br \/>  Test::~Test()<\/td>\n<td>nop \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u043c \u043f\u0443\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<br \/>  value \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0443\u0441\u043e\u0440 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430.<\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2, -O3<\/td>\n<td>0<\/td>\n<td>rnd: 1804289383<br \/>  Test::Test(142)<br \/>  142<br \/>  Test::~Test()<\/td>\n<td>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 if (v == 1) \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f. \u0411\u043b\u043e\u043a else if \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u043e else.<\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>macOs X Apple clang version 11.0.0<\/b><\/td>\n<\/tr>\n<tr>\n<td>-O0<\/td>\n<td>The program has unexpectedly finished.<\/td>\n<td>rnd: 16807<\/td>\n<td>ud2<\/td>\n<\/tr>\n<tr>\n<td>-O1, -O2<\/td>\n<td>0<\/td>\n<td>rnd: 16807<br \/>  Test::Test(142)<br \/>  142<br \/>  Test::~Test()<\/td>\n<td>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 if (v == 1) \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f. \u0411\u043b\u043e\u043a else if \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u043e else.<\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\"><b>Windows MSVC 2019 16.5.4<\/b><\/td>\n<\/tr>\n<tr>\n<td>\/Od \/RTCs<\/td>\n<td>Access violation reading location 0x00000000CCCCCCCC<\/td>\n<td>rnd: 41<\/td>\n<td>\u041f\u043e\u0431\u043e\u0447\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 MSVC stack frame run-time error checking<\/td>\n<\/tr>\n<tr>\n<td>\/Od, \/O1, \/O2<\/td>\n<td>0<\/td>\n<td>rnd: 41<br \/>  8791061810776<br \/>  Test::~Test()  <\/td>\n<td>\u041c\u0443\u0441\u043e\u0440 \u0438\u0437 \u044f\u0447\u0435\u0439\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438, \u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0432 rax<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<p>  \u041e\u043f\u044f\u0442\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432: \u043a\u0440\u043e\u043c\u0435 \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e ud2 \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c 4 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<br \/>  \u0412\u0435\u0441\u044c\u043c\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432 \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c:<br \/>   \u2014 \u0432 \u043e\u0434\u043d\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043b\u043e\u0441\u044c \u0431\u0435\u0437 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u2014 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438;<br \/>   \u2014 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0451\u043b \u0432\u044b\u0437\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u043d\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u043f\u0443\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e.<\/p>\n<h4>Linux x86-x64 Clang 10.0.0, -O1, -O2<\/h4>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/z7\/cq\/ry\/z7cqry23rk0ul156zrdhnedehl0.png\" alt=\"image\"><br \/>  \u0412 \u043a\u043e\u0434\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (\u0441\u0442\u0440\u043e\u043a\u0430 14), \u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 (\u0441\u0442\u0440\u043e\u043a\u0430 15). \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u0432\u0442\u043e\u0440\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0445\u043e\u0434.<br \/>  \u042d\u0442\u043e \u043d\u0430\u0432\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u043e\u0434\u043e\u0437\u0440\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442.<br \/>  \u041d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e if \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/>   \u2014 \u0435\u0441\u043b\u0438 \u0432\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u043d\u044b\u043c \u2014 \u043d\u0430\u0434\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 Test \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c 142;<br \/>   \u2014 \u0435\u0441\u043b\u0438 \u0432\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435 \u0432\u0435\u0440\u043d\u044b\u043c \u2014 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u0432\u043e\u0437\u0440\u0430\u0442\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e. \u0412 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u2014 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0441 \u0442\u0435\u043c \u0436\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c;<br \/>   \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u043d\u0435\u0439, \u0432\u044b\u0437\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 Test \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c 142 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f.<\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442, \u0435\u0441\u043b\u0438 \u0432\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0441 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u043c\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0430\u043c\u0438:  <\/p>\n<pre><code class=\"cpp\">Test bad(int v) {     if (v == 0) {         return {42};     } else if (v == rand()) {         return {142};     } } <\/code><\/pre>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;stdlib.h&gt;  struct Test {     Test(uint64_t v)         : value(v)     {         std::cout &lt;&lt; &quot;Test::Test(&quot; &lt;&lt; v &lt;&lt; &quot;)&quot; &lt;&lt; std::endl;     }     ~Test()     {         std::cout &lt;&lt; &quot;Test::~Test()&quot; &lt;&lt; std::endl;     }      uint64_t value; };  Test bad(int v) {     if (v == 0) {         return {42};     } else if (v == rand()) {         return {142};     } }  int main() {     const auto rnd = rand();     std::cout &lt;&lt; &quot;rnd: &quot; &lt;&lt; rnd &lt;&lt; std::endl;      std::cout &lt;&lt; bad(rnd).value &lt;&lt; std::endl;      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/j5\/mi\/-w\/j5mi-w148l3tnejie9aaxus5nr8.png\" alt=\"image\"><br \/>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0447\u0435\u0441\u0442\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0451\u043b \u0432\u0441\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b, \u0432\u044b\u0437\u0432\u0430\u0432 rand() (\u0441\u0442\u0440\u043e\u043a\u0430 16), \u0447\u0435\u043c \u0440\u0430\u0437\u0432\u0435\u044f\u043b \u0441\u043e\u043c\u043d\u0435\u043d\u0438\u044f \u043e \u043d\u0435\u043f\u043e\u0434\u043e\u0431\u0430\u044e\u0449\u0435 \u0440\u0430\u043d\u043d\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<\/p>\n<h4>Windows MSVC 2019 16.5.4, \/Od \/RTCs<\/h4>\n<p>  \u041e\u043f\u0446\u0438\u044f \/RTCs \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 stack frame run-time error checking. \u042d\u0442\u0430 \u043e\u043f\u0446\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 debug-\u0441\u0431\u043e\u0440\u043a\u0435. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0438\u0437\u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0443\u0447\u0430\u0441\u0442\u043a\u0430 main():<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kl\/sr\/4y\/klsr4ygrimmzxwbwuqtvfd3xvmy.png\" alt=\"image\"><br \/>  \u041f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c bad(int) (\u0441\u0442\u0440\u043e\u043a\u0430 4) \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u2014 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 edx \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 rnd (\u0441\u0442\u0440\u043e\u043a\u0430 2), \u0438 \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 rcx \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 rsp+28h (\u0441\u0442\u0440\u043e\u043a\u0430 3).<br \/>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e, rsp+28 \u2014 \u0430\u0434\u0440\u0435\u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 bad(int).<br \/>  \u042d\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 19 \u0438 20 \u2014 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u044d\u0442\u043e\u0439 \u0436\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0432 rcx, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440.<br \/>  \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 \u0441\u0442\u0440\u043e\u043a 4 \u2014 18 \u043a \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0432\u044b\u0432\u043e\u0434 \u0432 stream \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0435\u0451 \u043f\u043e\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  \u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u044b\u0445 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432 MSVC, \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u043f\u043e\u0442\u043e\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0432 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 rdx. \u0412 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 rdx \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0434\u0440\u0435\u0441\u0430, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0432 rax (\u0441\u0442\u0440\u043e\u043a\u0430 9).<br \/>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043e\u0442 bad(int):<br \/>   \u2014 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 rcx (\u0442\u0443\u0442 \u043c\u044b \u0432\u0438\u0434\u0438\u043c RVO \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438);<br \/>   \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0430\u0434\u0440\u0435\u0441\u0430 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 rax.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u044e \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 bad(int):<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/c3\/vm\/-x\/c3vm-xwuhghbvtp6byyqwf6l6xg.png\" alt=\"image\"><br \/>   \u2014 \u0432 eax \u0437\u0430\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0xCCCCCCCC, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0438 Access violation (\u0441\u0442\u0440\u043e\u043a\u0430 9) (\u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u2014 \u0442\u043e\u043b\u044c\u043a\u043e 4 \u0431\u0430\u0439\u0442\u0430, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0438 AccessViolation \u0430\u0434\u0440\u0435\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 8 \u0431\u0430\u0439\u0442);<br \/>   \u2014 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 rep stos, \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e\u0449\u0430\u044f 0xC \u0446\u0438\u043a\u043b\u043e\u0432 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e eax \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0430\u0434\u0440\u0435\u0441\u0430 rdi (\u0441\u0442\u0440\u043e\u043a\u0430 10). \u042d\u0442\u043e 48 \u0431\u0430\u0439\u0442\u043e\u0432 \u2014 \u0440\u043e\u0432\u043d\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 6;<br \/>   \u2014 \u043d\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u043f\u0443\u0442\u044f\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432 rax \u0437\u0430\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 rsp+40h (\u0441\u0442\u0440\u043e\u043a\u0438 23, 36);<br \/>   \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 rcx (\u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 main() \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u0430\u0434\u0440\u0435\u0441 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f) \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0435\u043a \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 rsp+8 (\u0441\u0442\u0440\u043e\u043a\u0430 4);<br \/>   \u2014 \u0432 \u0441\u0442\u0435\u043a \u0432\u043f\u0438\u0445\u0438\u0432\u0430\u0435\u0442\u0441\u044f rdi, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044e rsp \u043d\u0430 8 (\u0441\u0442\u0440\u043e\u043a\u0430 5);<br \/>   \u2014 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f 30h \u0431\u0430\u0439\u0442 \u043f\u0443\u0442\u0451\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044e rsp (\u0441\u0442\u0440\u043e\u043a\u0430 6).<br \/>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, rsp+8 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 4 \u0438 rsp+40h \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u0434\u0430 \u2014 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<br \/>  \u041a\u043e\u0434 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u044b\u0439, \u0442.\u043a. \u0432 \u043d\u0451\u043c \u043d\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f rbp.<br \/>  \u0412 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0438 Access Violation \u0435\u0441\u0442\u044c \u0446\u0435\u043b\u044b\u0445 \u0434\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0438:<br \/>   \u2014 \u043d\u0443\u043b\u0438 \u0432 \u0441\u0442\u0430\u0440\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u2014 \u0442\u0430\u043c \u043c\u043e\u0433 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043c\u0443\u0441\u043e\u0440;<br \/>   \u2014 \u0430\u0434\u0440\u0435\u0441 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c.<br \/>  \u0421\u0443\u0434\u044f \u043f\u043e \u0432\u0441\u0435\u043c\u0443, \u043e\u043f\u0446\u0438\u044f \/RTCs \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0430 \u0437\u0430\u0442\u0438\u0440\u0430\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 Access Violation \u2014 \u043b\u0438\u0448\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442.<\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0434 \u0441\u043e \u0432\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u043e\u0439 \u043e\u043f\u0446\u0438\u0435\u0439 \/RTCs \u043e\u0442 \u043a\u043e\u0434\u0430 \u0431\u0435\u0437 \u043d\u0435\u0451.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/r4\/ai\/gh\/r4aighkarr9kdcerpk60u6jvdya.png\" alt=\"image\"><br \/>  \u041a\u043e\u0434 \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u0432 main() \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0442\u0435\u043a\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kq\/oi\/zt\/kqoizt0khccfqovtmw6qn_--xiq.png\" alt=\"image\"><br \/>  (\u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u044f \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043b \u0440\u044f\u0434\u043e\u043c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad(int) \u2014 \u0441 \/RTCs \u0438 \u0431\u0435\u0437)<br \/>  \u0411\u0435\u0437 \/RTCs \u0438\u0441\u0447\u0435\u0437\u043b\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f rep stos \u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043d\u0435\u0451 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 2a<\/h3>\n<p>  \u0421\u043d\u043e\u0432\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430.<\/p>\n<h4>Windows MSVC 2019 16.5.4, \/Od \/RTCs<\/h4>\n<p>  \u0421 \u043e\u043f\u0446\u0438\u0435\u0439 \/RTCs \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 bad(int) \u043a\u043e\u0434, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u043c\u043b\u0430\u0434\u0448\u0443\u044e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 rax \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a Access violation.<br \/>  \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c rax \u043a\u0430\u043a\u0438\u043c-\u043b\u0438\u0431\u043e \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c \u0430\u0434\u0440\u0435\u0441\u043e\u043c. \u042d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439: \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0442\u0435\u043b\u043e bad(int) \u0432\u044b\u0432\u043e\u0434 \u0447\u0435\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432 std::cout.  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;iostream&gt; #include &lt;stdlib.h&gt;  struct Test {     Test(uint64_t v)         : value(v)     {         std::cout &lt;&lt; &quot;Test::Test(&quot; &lt;&lt; v &lt;&lt; &quot;)&quot; &lt;&lt; std::endl;     }     ~Test()     {         std::cout &lt;&lt; &quot;Test::~Test()&quot; &lt;&lt; std::endl;     }      uint64_t value; };  Test bad(int v) {   std::cout &lt;&lt; &quot;rnd: &quot; &lt;&lt; v &lt;&lt; std::endl;      if (v == 0) {         return {42};     } else if (v == 1) {         return {142};     } }  int main() {     const auto rnd = rand();      std::cout &lt;&lt; bad(rnd).value &lt;&lt; std::endl;      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<blockquote><p>rnd: 41<br \/>  8791039331928<br \/>  Test::~Test()  <\/p><\/blockquote>\n<p>  operator&lt;&lt; \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 stream, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 std::cout \u0432 rax. \u0410\u0434\u0440\u0435\u0441 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0442\u044c. Access violation \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0451\u043d.<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434<\/h2>\n<p>  \u041d\u0430 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c:<br \/>   \u2014 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043a\u0430 10 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f;<br \/>   \u2014 \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u0445 \u0443\u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p>  \u0412\u0441\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0447\u0451\u0442\u043a\u043e\u0435 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443 \u2014 \u043d\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0435 \u043d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u044c\u0448\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e. \u041d\u043e \u0438 \u0432 \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432 \u043d\u0435 \u043e\u0442\u043a\u0430\u0436\u0435\u0448\u044c.<\/p>\n<p>  \u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u043d\u043a\u0438\u0445 \u043d\u044e\u0430\u043d\u0441\u043e\u0432: \u0441\u0442\u043e\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u043e\u0434\u043d\u0443, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0443\u044e\u0441\u044f \u043a \u0434\u0435\u043b\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u0434\u0430 \u2014 \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0449\u0435 \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434, \u0447\u0435\u043c \u043f\u043e\u0442\u043e\u043c \u0440\u0430\u0437\u0433\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0440\u0435\u0431\u0443\u0441\u044b.<\/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=\"https:\/\/habr.com\/ru\/post\/499020\/\"> https:\/\/habr.com\/ru\/post\/499020\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/499020\/\">\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0435\u0433\u043e \u0432 c++ \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u043d\u0435-void \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u0432\u044b\u0437\u043e\u0432\u0430 return \u0441 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c. \u0421\u0442\u0430\u0442\u044c\u044f \u043d\u043e\u0441\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0430\u0443\u0447\u043d\u043e-\u0440\u0430\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440, \u0447\u0435\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439.<br \/>  \u041a\u043e\u043c\u0443 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0432\u0435\u0441\u0435\u043b\u043e \u0441\u043a\u0430\u043a\u0430\u0442\u044c \u043f\u043e \u0433\u0440\u0430\u0431\u043b\u044f\u043c \u2014 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043c\u043e, \u043d\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u0441\u044f.  <\/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-303743","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303743","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=303743"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303743\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}