{"id":354145,"date":"2024-05-20T22:42:30","date_gmt":"2024-05-20T22:42:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=354145"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=354145","title":{"rendered":"<span>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 GCC 13 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PVS-Studio<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432 GCC. \u0414\u0430, \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435 \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u043e \u0441\u0447\u0451\u0442\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u044d\u0442\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0435\u0439 \u044f\u0437\u044b\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u0441\u0442\u043e\u044f\u0442 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0438 \u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u0432\u043b\u0435\u0447\u0451\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 GCC. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0446\u0435\u043b\u044c \u2014 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043a\u043e\u0434\u0435 GCC \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/13e\/32c\/db0\/13e32cdb022b2d53be4cef73838c7790.png\" alt=\"1067_GCC13_ru\/image1.png\" title=\"\" width=\"1600\" height=\"902\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/13e\/32c\/db0\/13e32cdb022b2d53be4cef73838c7790.png\"\/><\/figure>\n<p>\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432 GCC \u0432\u0435\u0434\u0451\u0442 \u0441\u0432\u043e\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0441 1987 \u0433\u043e\u0434\u0430, \u0442.\u0435. 36 \u043b\u0435\u0442, \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u0436\u0438\u0437\u043d\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u043b\u0430 \u0432 \u0441\u0435\u0431\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u0430 \u0421, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0442\u0430\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u043a\u0430\u043a C++, Objective-C, Java, \u0424\u043e\u0440\u0442\u0440\u0430\u043d, Ada, Go, GAS \u0438 D. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0430\u043c\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u043c\u0430\u0436\u043e\u0440\u043d\u043e\u0439 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 GCC \u044f\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0432\u0435\u0440\u0441\u0438\u044f 13. \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0441\u0438\u044f 13.1. \u0417\u0430 \u0441\u0432\u043e\u044e \u0434\u043e\u043b\u0433\u0443\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f GCC \u043e\u0431\u0437\u0430\u0432\u0451\u043b\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u043e\u0435\u043a\u0442 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0438 \u043d\u0430\u0439\u0442\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u0442\u0430\u043a\u043e\u043c \u043e\u0442\u043b\u0430\u0436\u0435\u043d\u043d\u043e\u043c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u2014 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430.<\/p>\n<p>\u041a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 <a href=\"https:\/\/gcc.gnu.org\/codingconventions.html\">\u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044e<\/a> \u0441 \u043e\u0431\u0438\u043b\u044c\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u043a\u043e\u0448\u043c\u0430\u0440\u043e\u043c \u0434\u043b\u044f \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0443 PVS-Studio, \u043d\u043e \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e. \u041d\u0438\u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e 10 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043d\u044f \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0431\u0435\u0433\u043b\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043e\u0442\u0447\u0451\u0442\u0430, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0451\u043d \u0432 \u0441\u0438\u043b\u0443 \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u0447\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u0436\u0435\u043b\u0430\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 GCC, \u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043f\u043e <a href=\"https:\/\/pvs-studio.ru\/ru\/blog\/posts\/cpp\/0727\/\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N1. \u041d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h3>\n<pre><code class=\"cpp\">static ctf_id_t gen_ctf_function_type (ctf_container_ref ctfc,                        dw_die_ref function,                        bool from_global_func) { ....   ctf_funcinfo_t func_info;                                   \/\/ &lt;=   ....   {     ....     if (....)     {       do       {        ....          if (....)           ....         else if (....)         {           func_info.ctc_flags |= CTF_FUNC_VARARG;             \/\/ &lt;=           ....         }       }     }   ....   } .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V614 Uninitialized variable &#8216;func_info.ctc_flags&#8217; used. gcc\/dwarf2ctf.cc 676<\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442 <em>func_info<\/em> \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438. \u0417\u0430\u0442\u0435\u043c \u043d\u0438\u0436\u0435 \u043f\u043e \u043a\u043e\u0434\u0443 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0432\u0435\u0442\u043e\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430 <em>CTF_FUNC_VARARG<\/em> \u0432 \u043f\u043e\u043b\u0435 <em>ctc_flags<\/em>, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043e.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N2. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c<\/h3>\n<pre><code class=\"cpp\">static struct gcov_info * read_gcda_file (const char *filename) {   ....   curr_gcov_info = obj_info =      (struct gcov_info *) xcalloc (sizeof (struct gcov_info) +           sizeof (struct gcov_ctr_info) * GCOV_COUNTERS, 1);    obj_info->version = version;   obj_info->filename = filename;   .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V522 There might be dereferencing of a potential null pointer &#8216;obj_info&#8217;. Check lines: 290, 287. libgcov-util.c 290. libgcov-util.c 287<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 PVS-Studio \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f <em>obj_info<\/em> \u043f\u043e\u0441\u043b\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438. \u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>xmalloc<\/em>, <em>xcalloc<\/em> \u0438 <em>xrealloc<\/em> <a href=\"https:\/\/man.freebsd.org\/cgi\/man.cgi?query=xmalloc&amp;apropos=0\">\u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442<\/a> \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u0435\u0440\u0432\u0451\u0442 \u0441\u0432\u043e\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u041a\u043e\u0433\u0434\u0430 \u044f \u0443\u0432\u0438\u0434\u0435\u043b \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435, \u0442\u043e \u043e\u0442\u043d\u0451\u0441 \u0435\u0433\u043e \u043a \u043b\u043e\u0436\u043d\u044b\u043c \u0438 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u043e\u0442\u043b\u0430\u0434\u043a\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u0442\u043a\u0440\u044b\u0432 \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u044b\u0437\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e <em>calloc<\/em>. \u0412\u043e\u0442 \u0432\u043e \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441 <em>xcalloc<\/em>:<\/p>\n<pre><code class=\"cpp\">\/\/ libgcc\/libgcov.h .... \/* work around the poisoned malloc\/calloc in system.h.  *\/ #ifndef xmalloc #define xmalloc malloc #endif #ifndef xcalloc #define xcalloc calloc #endif <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0432\u043e\u0441\u0445\u0438\u0449\u0430\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0445\u043e\u0447\u0443 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 <a href=\"https:\/\/pvs-studio.ru\/ru\/blog\/posts\/cpp\/0938\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u043e\u043b\u043b\u0435\u0433\u0438. \u0412 \u043d\u0435\u0439 \u043e\u043d \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b \u0434\u043e\u0432\u043e\u0434\u044b \u043a \u0442\u043e\u043c\u0443, \u0437\u0430\u0447\u0435\u043c \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N3. \u0417\u0430\u0431\u044b\u0442\u044b\u0439 JSON.<\/h3>\n<pre><code class=\"cpp\">static void generate_results (const char *file_name) {   ....    json::object *root = new json::object ();   root->set (\"format_version\", new json::string (\"1\"));   root->set (\"gcc_version\", new json::string (version_string));    if (....)     root->set (\"current_working_directory\", new json::string (bbg_cwd));   root->set (\"data_file\", new json::string (file_name));    json::array *json_files = new json::array ();   root->set (\"files\", json_files);  ....    if (....)   {       if (....)       {         root->dump (stdout);         printf (\"\\n\");       }       else       {         pretty_printer pp;         root->print (&amp;pp);         ....       }   } } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V773 The function was exited without releasing the &#8216;root&#8217; pointer. A memory leak is possible. <a href=\"http:\/\/gcov.cc\">gcov.cc<\/a> 1525<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 json-\u043e\u0431\u044a\u0435\u043a\u0442 root \u0437\u0430\u0431\u044b\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0443\u0442\u0435\u0447\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0442\u0430\u043a\u043e\u0439 \u0432\u044b\u0432\u043e\u0434 JSON \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0435\u0434\u0438\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u043e, \u0438 \u044d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442. \u0420\u0435\u0448\u0438\u043b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 PVS-Studio \u0432 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0443\u0442\u0435\u0447\u0435\u043a \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N4. \u041d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0431\u0443\u0444\u0435\u0440\u0430<\/h3>\n<pre><code class=\"cpp\">char m_flag_chars[256]; .... void flag_chars_t::add_char (char ch) {   int i = strlen (m_flag_chars);   m_flag_chars[i++] = ch;   m_flag_chars[i] = 0; } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V557 Array overrun is possible. The value of &#8216;i&#8217; index could reach 256. <a href=\"http:\/\/c-format.cc\">c-format.cc<\/a> 1994<\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0435 \u043a\u043e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u0432\u044b\u0445\u043e\u0434 \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0443\u043b\u044f, \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 <em>m_flag_chars<\/em> \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>add_char<\/em> \u0431\u044b\u043b\u0430 \u0440\u0430\u0432\u043d\u0430 255.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N5. \u041b\u0438\u0448\u043d\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/h3>\n<pre><code class=\"cpp\">.... \/* Return True when the format flag CHR has been used.  *\/ bool get_flag (char chr) const {   unsigned char c = chr &amp; 0xff;   return (flags[c \/ (CHAR_BIT * sizeof *flags)]     &amp; (1U &lt;&lt; (c % (CHAR_BIT * sizeof *flags)))); } .... static fmtresult format_floating (const directive &amp;dir, const HOST_WIDE_INT prec[2]) {   ....   unsigned flagmin = (1 \/* for the first digit *\/     + (dir.get_flag ('+') | dir.get_flag (' ')));          .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V792 The &#8216;get_flag&#8217; function located to the right of the operator &#8216;|&#8217; will be called regardless of the value of the left operand. Perhaps, it is better to use &#8216;||&#8217;. <a href=\"http:\/\/gimple-ssa-sprintf.cc\">gimple-ssa-sprintf.cc<\/a> 1227<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <em>get_flag<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 <em>bool<\/em>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u0432\u0443\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e &#171;\u0418\u041b\u0418&#187;. \u041e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043e\u0431\u0430 \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u0430. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c &#171;\u0418\u041b\u0418&#187;, \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0432\u0435\u0440\u043d\u0451\u0442 <em>true<\/em>:<\/p>\n<pre><code class=\"cpp\">unsigned flagmin = (1 \/* for the first digit *\/           + (dir.get_flag ('+') || dir.get_flag (' '))); <\/code><\/pre>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N6. \u0423\u0442\u0435\u0447\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438<\/h3>\n<pre><code class=\"cpp\">struct gcov_info * gcov_read_profile_dir (const char* dir_name,                        int recompute_summary ATTRIBUTE_UNUSED) {   char *pwd;   int ret;    read_profile_dir_init ();    if (access (dir_name, R_OK) != 0)   {     fnotice (stderr, \"cannot access directory %s\\n\", dir_name);     return NULL;   }   pwd = getcwd (NULL, 0);                                     \/\/ &lt;=   gcc_assert (pwd);   ret = chdir (dir_name);   if (ret != 0)   {     fnotice (stderr, \"%s is not a directory\\n\", dir_name);     return NULL;                                              \/\/ &lt;=   } #ifdef HAVE_FTW_H   ftw (\".\", ftw_read_file, 50); #endif   chdir (pwd);   free (pwd);                                                 \/\/ &lt;=   return gcov_info_head;; } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V773 The function was exited without releasing the &#8216;pwd&#8217; pointer. A memory leak is possible. libgcov-util.c 450, libgcov-util.c 434<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man3\/getcwd.3.html\"><em>getcwd<\/em><\/a>. \u0415\u0441\u043b\u0438 \u0435\u0439 \u043f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0434 \u0431\u0443\u0444\u0435\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u0443\u0434\u0430 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e. \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0432\u0435\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u043b \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u043e \u0437\u0430\u0431\u044b\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0432\u0435\u0442\u043e\u043a \u043a\u043e\u0434\u0430 \u0441 \u0440\u0430\u043d\u043d\u0438\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u043e\u043c. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432 \u043a\u043e\u0434\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f, \u0445\u043e\u0442\u044c \u0438 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f, \u0443\u0442\u0435\u0447\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438. \u041e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 PVS-Studio \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0443\u0442\u0435\u0447\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/pvs-studio.ru\/ru\/blog\/posts\/cpp\/0543\/\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">.... ret = chdir (dir_name); if (ret != 0) {   fnotice (stderr, \"%s is not a directory\\n\", dir_name);   free(pwd);   return NULL; } .... <\/code><\/pre>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N7. \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430<\/h3>\n<pre><code class=\"cpp\">static conversion * build_aggr_conv (tree type,                  tree ctor,                  int flags,                               \/\/ &lt;=                  tsubst_flags_t complain) {   unsigned HOST_WIDE_INT i = 0;   conversion *c;   tree field = next_aggregate_field (TYPE_FIELDS (type));   tree empty_ctor = NULL_TREE;   hash_set&lt;tree, true> pset;   flags = LOOKUP_IMPLICIT|LOOKUP_NO_NARROWING;            \/\/ &lt;=   .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V763 Parameter &#8216;flags&#8217; is always rewritten in function body before being used. <a href=\"http:\/\/call.cc\">call.cc<\/a> 994, <a href=\"http:\/\/call.cc\">call.cc<\/a> 981<\/p>\n<p>\u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u044b\u0439 \u043f\u043e \u043a\u043e\u043f\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>flags<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u043b\u0430\u0433\u0438 \u0432 \u044d\u0442\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N8. \u041d\u0435\u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0446\u0438\u043a\u043b<\/h3>\n<pre><code class=\"cpp\">void gt_pch_p_13ctf_container (ATTRIBUTE_UNUSED void *this_obj,                           void *x_p,                           ATTRIBUTE_UNUSED gt_pointer_operator op,                           ATTRIBUTE_UNUSED void *cookie) {   struct ctf_container * x ATTRIBUTE_UNUSED = (struct ctf_container *)x_p;   {     ....     size_t l0 = (size_t)(0);                                 \/\/ &lt;=     ....     if ((*x).ctfc_vars_list != NULL)      {       size_t i0;       for (i0 = 0; i0 != (size_t)(l0)                        \/\/ &lt;=            &amp;&amp; ((void *)(*x).ctfc_vars_list == this_obj); i0++)        {          if ((void *)((*x).ctfc_vars_list) == this_obj)            op (&amp;((*x).ctfc_vars_list[i0]), NULL, cookie);       }       ....     }   }   .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V621 Consider inspecting the &#8216;for&#8217; operator. It&#8217;s possible that the loop will be executed incorrectly or won&#8217;t be executed at all. <a href=\"http:\/\/gtype-desc.cc\">gtype-desc.cc<\/a> 11865<\/p>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>l0<\/em>, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0446\u0438\u043a\u043b\u0430, \u0442\u0430\u043a \u0438 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0440\u0430\u0432\u043d\u043e\u0439 \u043d\u0443\u043b\u044e, \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0447\u0435\u043c \u0446\u0438\u043a\u043b \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043d\u0430\u0447\u043d\u0451\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 PVS-Studio \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0434\u0430\u043b \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439. \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445:<\/p>\n<ul>\n<li>\n<p>V621 Consider inspecting the &#8216;for&#8217; operator. It&#8217;s possible that the loop will be executed incorrectly or won&#8217;t be executed at all.  <a href=\"http:\/\/gtype-desc.cc\">gtype-desc.cc<\/a> 11874<\/p>\n<\/li>\n<li>\n<p>V621 Consider inspecting the &#8216;for&#8217; operator. It&#8217;s possible that the loop will be executed incorrectly or won&#8217;t be executed at all.   <a href=\"http:\/\/gtype-desc.cc\">gtype-desc.cc<\/a> 11883<\/p>\n<\/li>\n<li>\n<p>V621 Consider inspecting the &#8216;for&#8217; operator. It&#8217;s possible that the loop will be executed incorrectly or won&#8217;t be executed at all. <a href=\"http:\/\/gtype-desc.cc\">gtype-desc.cc<\/a> 11892<\/p>\n<\/li>\n<\/ul>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N9. \u0421\u043e\u043c\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0446\u0438\u043a\u043b<\/h3>\n<pre><code class=\"cpp\">static bool combine_reaching_defs (ext_cand *cand,                        const_rtx set_pat,                        ext_state *state) {   ....   while (   REG_P (SET_SRC (*dest_sub_rtx))          &amp;&amp; (REGNO (SET_SRC (*dest_sub_rtx)) == REGNO (SET_DEST (set))))   {     ....     if (....)       break;      if (....)       break;          ....     break;   } } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V612 An unconditional &#8216;break&#8217; within a loop. <a href=\"http:\/\/ree.cc\">ree.cc<\/a> 985<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 PVS-Studio \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438 \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0440\u0443\u0433\u0438\u0445 <em>break<\/em> \u043f\u043e\u0434 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438.  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>goto<\/em>, \u0447\u0442\u043e, \u043e\u0434\u043d\u0430\u043a\u043e, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0435\u0433\u043e \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0446\u0435\u043b\u043e\u043c \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N10. \u0421\u0442\u0440\u0430\u043d\u043d\u043e\u0435 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435<\/h3>\n<pre><code class=\"cpp\">void const_fn_result_svalue::dump_to_pp(pretty_printer *pp,                                    bool simple) const {   if (simple)   {     pp_printf (pp, \"CONST_FN_RESULT(%qD, {\", m_fndecl);     for (unsigned i = 0; i &lt; m_num_inputs; i++)     {       if (i > 0)         pp_string (pp, \", \");       dump_input (pp, i, m_input_arr[i], simple);     }     pp_string (pp, \"})\");   }   else   {     pp_printf (pp, \"CONST_FN_RESULT(%qD, {\", m_fndecl);     for (unsigned i = 0; i &lt; m_num_inputs; i++)     {       if (i > 0)         pp_string (pp, \", \");       dump_input (pp, i, m_input_arr[i], simple);     }       pp_string (pp, \"})\");   } } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V523 The &#8216;then&#8217; statement is equivalent to the &#8216;else&#8217; statement. <a href=\"http:\/\/svalue.cc\">svalue.cc<\/a> 2009, <a href=\"http:\/\/svalue.cc\">svalue.cc<\/a> 1998<\/p>\n<p>\u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0435 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u0432 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u0432\u0435\u0442\u043a\u0430\u0445. \u042f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 git log \u2013follow -p .\/gcc\/analyzer\/svalue.cc \u0432 \u043a\u043e\u0440\u043d\u0435 git \u043f\u0440\u043e\u0435\u043a\u0442\u0430 GCC, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043c\u0438\u0442\u0430\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u0442\u0430\u043c \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0444\u0430\u0439\u043b \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0441 \u044d\u0442\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u044b, \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0443\u0441\u0442\u0430\u043b\u043e\u0441\u0442\u044c. \u041d\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u0442\u0430\u043b\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u043f\u0435\u043d\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0435\u043c \u043e\u0442 \u0444\u0430\u043a\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0442\u0430\u043a\u0438\u043c \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u043a\u0430\u043a GCC. PVS-Studio \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b \u0441\u0432\u043e\u044e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0430\u043b\u043e\u0437\u0430\u043c\u0435\u0442\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u0430\u0436\u0435 \u0432 \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u0442\u043b\u0430\u0436\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432\u044b\u0445 \u0431\u0430\u0437\u0430\u0445, \u0438 \u0434\u0430\u0436\u0435 \u0437\u0430\u0432\u0435\u0441\u0430 \u0438\u0437 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u043d\u0435 \u0441\u0442\u0430\u043b\u0430 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435\u043c.<\/p>\n<p>\u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0436\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0435\u043c \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u043d\u0435 \u043f\u043b\u043e\u0434\u0438\u0442\u044c \u0431\u0430\u0433\u0438 \u0432 \u0440\u0435\u043b\u0438\u0437 \ud83d\ude42 \u041d\u0443 \u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u0441\u043b\u0443\u0447\u0430\u0435\u043c, \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u044e <a href=\"https:\/\/pvs-studio.ru\/ru\/pvs-studio\/download\/?utm_source=website&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=1067\">\u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c<\/a> \u0442\u0440\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0438 <a href=\"https:\/\/pvs-studio.ru\/ru\/subscribe\/\">\u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f<\/a> \u043d\u0430 \u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442 \u043d\u0430\u0448\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0441 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0435\u0439, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: Ignat Grishechko. <a href=\"https:\/\/pvs-studio.com\/en\/blog\/posts\/cpp\/1067\/\">Checking the GCC 13 compiler with the help of PVS-Studio<\/a>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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\/articles\/759278\/\"> https:\/\/habr.com\/ru\/articles\/759278\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432 GCC. \u0414\u0430, \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435 \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u043e \u0441\u0447\u0451\u0442\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u044d\u0442\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0435\u0439 \u044f\u0437\u044b\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u0441\u0442\u043e\u044f\u0442 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435, \u0438 \u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u0432\u043b\u0435\u0447\u0451\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 GCC. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0446\u0435\u043b\u044c \u2014 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043a\u043e\u0434\u0435 GCC \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432 GCC \u0432\u0435\u0434\u0451\u0442 \u0441\u0432\u043e\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0441 1987 \u0433\u043e\u0434\u0430, \u0442.\u0435. 36 \u043b\u0435\u0442, \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u0436\u0438\u0437\u043d\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043d\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u043b\u0430 \u0432 \u0441\u0435\u0431\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u0430 \u0421, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0442\u0430\u043a\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432, \u043a\u0430\u043a C++, Objective-C, Java, \u0424\u043e\u0440\u0442\u0440\u0430\u043d, Ada, Go, GAS \u0438 D. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0430\u043c\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u043c\u0430\u0436\u043e\u0440\u043d\u043e\u0439 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 GCC \u044f\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0432\u0435\u0440\u0441\u0438\u044f 13. \u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0441\u0438\u044f 13.1. \u0417\u0430 \u0441\u0432\u043e\u044e \u0434\u043e\u043b\u0433\u0443\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f GCC \u043e\u0431\u0437\u0430\u0432\u0451\u043b\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u043e\u0435\u043a\u0442 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0438 \u043d\u0430\u0439\u0442\u0438 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u0442\u0430\u043a\u043e\u043c \u043e\u0442\u043b\u0430\u0436\u0435\u043d\u043d\u043e\u043c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u2014 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430.<\/p>\n<p>\u041a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 <a href=\"https:\/\/gcc.gnu.org\/codingconventions.html\">\u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044e<\/a> \u0441 \u043e\u0431\u0438\u043b\u044c\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u0447\u0442\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u043a\u043e\u0448\u043c\u0430\u0440\u043e\u043c \u0434\u043b\u044f \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u042d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0443 PVS-Studio, \u043d\u043e \u043d\u0435 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e. \u041d\u0438\u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e 10 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043d\u044f \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0431\u0435\u0433\u043b\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043e\u0442\u0447\u0451\u0442\u0430, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0451\u043d \u0432 \u0441\u0438\u043b\u0443 \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u0447\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u0436\u0435\u043b\u0430\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u043d\u043d\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 GCC, \u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043f\u043e <a href=\"https:\/\/pvs-studio.ru\/ru\/blog\/posts\/cpp\/0727\/\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N1. \u041d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430<\/h3>\n<pre><code class=\"cpp\">static ctf_id_t gen_ctf_function_type (ctf_container_ref ctfc,                        dw_die_ref function,                        bool from_global_func) { ....   ctf_funcinfo_t func_info;                                   \/\/ &lt;=   ....   {     ....     if (....)     {       do       {        ....          if (....)           ....         else if (....)         {           func_info.ctc_flags |= CTF_FUNC_VARARG;             \/\/ &lt;=           ....         }       }     }   ....   } .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V614 Uninitialized variable &#8216;func_info.ctc_flags&#8217; used. gcc\/dwarf2ctf.cc 676<\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442 <em>func_info<\/em> \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438. \u0417\u0430\u0442\u0435\u043c \u043d\u0438\u0436\u0435 \u043f\u043e \u043a\u043e\u0434\u0443 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0432\u0435\u0442\u043e\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430 <em>CTF_FUNC_VARARG<\/em> \u0432 \u043f\u043e\u043b\u0435 <em>ctc_flags<\/em>, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043e.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N2. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c<\/h3>\n<pre><code class=\"cpp\">static struct gcov_info * read_gcda_file (const char *filename) {   ....   curr_gcov_info = obj_info =      (struct gcov_info *) xcalloc (sizeof (struct gcov_info) +           sizeof (struct gcov_ctr_info) * GCOV_COUNTERS, 1);    obj_info->version = version;   obj_info->filename = filename;   .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V522 There might be dereferencing of a potential null pointer &#8216;obj_info&#8217;. Check lines: 290, 287. libgcov-util.c 290. libgcov-util.c 287<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 PVS-Studio \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f <em>obj_info<\/em> \u043f\u043e\u0441\u043b\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438. \u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>xmalloc<\/em>, <em>xcalloc<\/em> \u0438 <em>xrealloc<\/em> <a href=\"https:\/\/man.freebsd.org\/cgi\/man.cgi?query=xmalloc&amp;apropos=0\">\u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442<\/a> \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u0435\u0440\u0432\u0451\u0442 \u0441\u0432\u043e\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u041a\u043e\u0433\u0434\u0430 \u044f \u0443\u0432\u0438\u0434\u0435\u043b \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435, \u0442\u043e \u043e\u0442\u043d\u0451\u0441 \u0435\u0433\u043e \u043a \u043b\u043e\u0436\u043d\u044b\u043c \u0438 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u043e\u0442\u043b\u0430\u0434\u043a\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u0442\u043a\u0440\u044b\u0432 \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u044b\u0437\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e <em>calloc<\/em>. \u0412\u043e\u0442 \u0432\u043e \u0447\u0442\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441 <em>xcalloc<\/em>:<\/p>\n<pre><code class=\"cpp\">\/\/ libgcc\/libgcov.h .... \/* work around the poisoned malloc\/calloc in system.h.  *\/ #ifndef xmalloc #define xmalloc malloc #endif #ifndef xcalloc #define xcalloc calloc #endif <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0432\u043e\u0441\u0445\u0438\u0449\u0430\u044f \u0431\u0443\u0434\u0443\u0449\u0438\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0445\u043e\u0447\u0443 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 <a href=\"https:\/\/pvs-studio.ru\/ru\/blog\/posts\/cpp\/0938\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u043e\u043b\u043b\u0435\u0433\u0438. \u0412 \u043d\u0435\u0439 \u043e\u043d \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b \u0434\u043e\u0432\u043e\u0434\u044b \u043a \u0442\u043e\u043c\u0443, \u0437\u0430\u0447\u0435\u043c \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N3. \u0417\u0430\u0431\u044b\u0442\u044b\u0439 JSON.<\/h3>\n<pre><code class=\"cpp\">static void generate_results (const char *file_name) {   ....    json::object *root = new json::object ();   root->set (\"format_version\", new json::string (\"1\"));   root->set (\"gcc_version\", new json::string (version_string));    if (....)     root->set (\"current_working_directory\", new json::string (bbg_cwd));   root->set (\"data_file\", new json::string (file_name));    json::array *json_files = new json::array ();   root->set (\"files\", json_files);  ....    if (....)   {       if (....)       {         root->dump (stdout);         printf (\"\\n\");       }       else       {         pretty_printer pp;         root->print (&amp;pp);         ....       }   } } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V773 The function was exited without releasing the &#8216;root&#8217; pointer. A memory leak is possible. <a href=\"http:\/\/gcov.cc\">gcov.cc<\/a> 1525<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 json-\u043e\u0431\u044a\u0435\u043a\u0442 root \u0437\u0430\u0431\u044b\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0443\u0442\u0435\u0447\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0442\u0430\u043a\u043e\u0439 \u0432\u044b\u0432\u043e\u0434 JSON \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0435\u0434\u0438\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u043e, \u0438 \u044d\u0442\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442. \u0420\u0435\u0448\u0438\u043b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 PVS-Studio \u0432 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0443\u0442\u0435\u0447\u0435\u043a \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N4. \u041d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0431\u0443\u0444\u0435\u0440\u0430<\/h3>\n<pre><code class=\"cpp\">char m_flag_chars[256]; .... void flag_chars_t::add_char (char ch) {   int i = strlen (m_flag_chars);   m_flag_chars[i++] = ch;   m_flag_chars[i] = 0; } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V557 Array overrun is possible. The value of &#8216;i&#8217; index could reach 256. <a href=\"http:\/\/c-format.cc\">c-format.cc<\/a> 1994<\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0435 \u043a\u043e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u0432\u044b\u0445\u043e\u0434 \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0443\u043b\u044f, \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 <em>m_flag_chars<\/em> \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>add_char<\/em> \u0431\u044b\u043b\u0430 \u0440\u0430\u0432\u043d\u0430 255.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N5. \u041b\u0438\u0448\u043d\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f<\/h3>\n<pre><code class=\"cpp\">.... \/* Return True when the format flag CHR has been used.  *\/ bool get_flag (char chr) const {   unsigned char c = chr &amp; 0xff;   return (flags[c \/ (CHAR_BIT * sizeof *flags)]     &amp; (1U &lt;&lt; (c % (CHAR_BIT * sizeof *flags)))); } .... static fmtresult format_floating (const directive &amp;dir, const HOST_WIDE_INT prec[2]) {   ....   unsigned flagmin = (1 \/* for the first digit *\/     + (dir.get_flag ('+') | dir.get_flag (' ')));          .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V792 The &#8216;get_flag&#8217; function located to the right of the operator &#8216;|&#8217; will be called regardless of the value of the left operand. Perhaps, it is better to use &#8216;||&#8217;. <a href=\"http:\/\/gimple-ssa-sprintf.cc\">gimple-ssa-sprintf.cc<\/a> 1227<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <em>get_flag<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 <em>bool<\/em>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u0432\u0443\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u043e\u0433\u043e &#171;\u0418\u041b\u0418&#187;. \u041e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043e\u0431\u0430 \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u0430. \u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c &#171;\u0418\u041b\u0418&#187;, \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0432\u0435\u0440\u043d\u0451\u0442 <em>true<\/em>:<\/p>\n<pre><code class=\"cpp\">unsigned flagmin = (1 \/* for the first digit *\/           + (dir.get_flag ('+') || dir.get_flag (' '))); <\/code><\/pre>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N6. \u0423\u0442\u0435\u0447\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438<\/h3>\n<pre><code class=\"cpp\">struct gcov_info * gcov_read_profile_dir (const char* dir_name,                        int recompute_summary ATTRIBUTE_UNUSED) {   char *pwd;   int ret;    read_profile_dir_init ();    if (access (dir_name, R_OK) != 0)   {     fnotice (stderr, \"cannot access directory %s\\n\", dir_name);     return NULL;   }   pwd = getcwd (NULL, 0);                                     \/\/ &lt;=   gcc_assert (pwd);   ret = chdir (dir_name);   if (ret != 0)   {     fnotice (stderr, \"%s is not a directory\\n\", dir_name);     return NULL;                                              \/\/ &lt;=   } #ifdef HAVE_FTW_H   ftw (\".\", ftw_read_file, 50); #endif   chdir (pwd);   free (pwd);                                                 \/\/ &lt;=   return gcov_info_head;; } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V773 The function was exited without releasing the &#8216;pwd&#8217; pointer. A memory leak is possible. libgcov-util.c 450, libgcov-util.c 434<\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/man7.org\/linux\/man-pages\/man3\/getcwd.3.html\"><em>getcwd<\/em><\/a>. \u0415\u0441\u043b\u0438 \u0435\u0439 \u043f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0434 \u0431\u0443\u0444\u0435\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u0443\u0434\u0430 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e. \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0432\u0435\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u043b \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u043e \u0437\u0430\u0431\u044b\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0432\u0435\u0442\u043e\u043a \u043a\u043e\u0434\u0430 \u0441 \u0440\u0430\u043d\u043d\u0438\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u043e\u043c. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432 \u043a\u043e\u0434\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f, \u0445\u043e\u0442\u044c \u0438 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f, \u0443\u0442\u0435\u0447\u043a\u0430 \u043f\u0430\u043c\u044f\u0442\u0438. \u041e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 PVS-Studio \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0443\u0442\u0435\u0447\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/pvs-studio.ru\/ru\/blog\/posts\/cpp\/0543\/\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">.... ret = chdir (dir_name); if (ret != 0) {   fnotice (stderr, \"%s is not a directory\\n\", dir_name);   free(pwd);   return NULL; } .... <\/code><\/pre>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N7. \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430<\/h3>\n<pre><code class=\"cpp\">static conversion * build_aggr_conv (tree type,                  tree ctor,                  int flags,                               \/\/ &lt;=                  tsubst_flags_t complain) {   unsigned HOST_WIDE_INT i = 0;   conversion *c;   tree field = next_aggregate_field (TYPE_FIELDS (type));   tree empty_ctor = NULL_TREE;   hash_set&lt;tree, true> pset;   flags = LOOKUP_IMPLICIT|LOOKUP_NO_NARROWING;            \/\/ &lt;=   .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio: V763 Parameter &#8216;flags&#8217; is always rewritten in function body before being used. <a href=\"http:\/\/call.cc\">call.cc<\/a> 994, <a href=\"http:\/\/call.cc\">call.cc<\/a> 981<\/p>\n<p>\u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u044b\u0439 \u043f\u043e \u043a\u043e\u043f\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <em>flags<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u043b\u0430\u0433\u0438 \u0432 \u044d\u0442\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f.<\/p>\n<h3>\u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 N8. \u041d\u0435\u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0446\u0438\u043a\u043b<\/h3>\n<pre><code class=\"cpp\">void gt_pch_p_13ctf_container (ATTRIBUTE_UNUSED void *this_obj,                           void *x_p,                           ATTRIBUTE_UNUSED gt_pointer_operator op,                           ATTRIBUTE_UNUSED void *cookie) {   struct ctf_container * x ATTRIBUTE_UNUSED = (struct ctf_container *)x_p;   {     ....     size_t l0 = (size_t)(0);                                 \/\/ &lt;=     ....     if ((*x).ctfc_vars_list != NULL)      {       size_t i0;       for (i0 = 0; i0 != (size_t)(l0)                        \/\/ &lt;=            &amp;&amp; ((void *)(*x).ctfc_vars_list == this_obj); i0++)        {          if ((void *)((*x).ctfc_vars_list) == this_obj)            op (&amp;((*x).ctfc_vars_list[i0]), NULL, cookie);       }       ....     }   }   .... } <\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-354145","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354145","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=354145"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354145\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=354145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=354145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=354145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}