{"id":1173,"date":"2013-03-27T16:38:08","date_gmt":"2013-03-27T06:38:08","guid":{"rendered":"http:\/\/brnz.org\/hbr\/?p=1173"},"modified":"2013-03-27T16:38:08","modified_gmt":"2013-03-27T06:38:08","slug":"bug-review-2013-03-26","status":"publish","type":"post","link":"https:\/\/brnz.org\/hbr\/?p=1173","title":{"rendered":"Bug review, 2013-03-26"},"content":{"rendered":"<p>Last week, I started writing about runtime bugs that I&#8217;ve encountered in my own code, for my own interest and potential benefit. This post contains a summary of the issues I noticed, and a brief self-review of the week.<\/p>\n<h2><span style=\"font-size: 1.285714286rem; line-height: 1.6;\">Summary of the week<\/span><\/h2>\n<p><a title=\"Bugs of the day,  Tuesday 2013-03-19\" href=\"https:\/\/brnz.org\/hbr\/?p=1114\">Tuesday<\/a><\/p>\n<ul>\n<li>Changed virtual function prototype results in correct function not being called<\/li>\n<li>memcpy() into an uninitialized pointer variable<\/li>\n<li>Bad loop counting<\/li>\n<li>Failing to store updated state<\/li>\n<\/ul>\n<p><a title=\"Bugs of the day, Wednesday 2013-03-20\" href=\"https:\/\/brnz.org\/hbr\/?p=1124\">Wednesday<\/a><\/p>\n<ul>\n<li>Uninitialized class member<\/li>\n<li>Sliced inheritance<\/li>\n<li>Undesired printf() output<\/li>\n<\/ul>\n<p><a title=\"Bugs of the day, Thursday 2013-03-21\" href=\"https:\/\/brnz.org\/hbr\/?p=1135\">Thursday<\/a><\/p>\n<ul>\n<li>Failed to initialize instance-specific member variable correctly because I was calling the wrong constructor<\/li>\n<li>Use of uninitialized system<\/li>\n<li>Yet another uninitialized member variable crash<\/li>\n<\/ul>\n<p><a title=\"Bugs of the day, Friday 2013-03-22\" href=\"https:\/\/brnz.org\/hbr\/?p=1139\">Friday<\/a><\/p>\n<ul>\n<li>Unexpected use of class<\/li>\n<li>Hard-coded array size, no checking<\/li>\n<li>General disaster<\/li>\n<\/ul>\n<p><a title=\"Bugs of the day, Monday 2013-03-25\" href=\"https:\/\/brnz.org\/hbr\/?p=1159\">Monday<\/a><\/p>\n<ul>\n<li>Initialized, but not in the right order (fallout from Unexpected use of class)<\/li>\n<\/ul>\n<p><a title=\"Bugs of the day, Tuesday 2013-03-26\" href=\"https:\/\/brnz.org\/hbr\/?p=1167\">Tuesday<\/a><\/p>\n<ul>\n<li>Local static state is local, static<\/li>\n<li>Redux: Changed virtual function prototype results in correct function not being called<\/li>\n<\/ul>\n<h2>Trends<\/h2>\n<p>Looking back over the week, failure to initialize, failure to init at the right time or in the right order stands out as a primary source of bugs. Maybe I need to be asking myself questions like &#8220;where did this variable&#8217;s state come from&#8221; to try and prompt more consideration of this.<\/p>\n<p>Broadly, there is also what appears to be insufficient familiarity with various of C++&#8217;s OO features, resulting in silly mistakes. I don&#8217;t generally write much OO-style code &#8212; this week has been unusual in that way. It is a problem if I can&#8217;t use them reliably.<em><br \/>\n<\/em><\/p>\n<p>I&#8217;m pretty happy with <a title=\"Bugs of the day, Tuesday 2013-03-26\" href=\"https:\/\/brnz.org\/hbr\/?p=1167\">the solution<\/a> to the &#8220;<a title=\"Bugs of the day,  Tuesday 2013-03-19\" href=\"https:\/\/brnz.org\/hbr\/?p=1114\">Changed version prototype<\/a>&#8221;\u00a0situation. Finding ways to prevent possible runtime bugs at compile-time always feels like a worthy achievement.<\/p>\n<h2>Meta<\/h2>\n<p>Thus far, I&#8217;ve found the process of logging these bugs to be worthwhile &#8212; attempting to explain the bugs helps me to understand them more clearly. I have found myself thinking about the bugs: the solutions I&#8217;ve attempted, and how to try to avoid writing the same bugs in the future.<\/p>\n<p>My plan for now is to continue to write these posts. Hopefully, it leads to fewer bugs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week, I started writing about runtime bugs that I&#8217;ve encountered in my own code, for my own interest and potential benefit. This post contains a summary of the issues I noticed, and a brief self-review of the week. Summary of the week Tuesday Changed virtual function prototype results in correct function not being called &hellip; <a href=\"https:\/\/brnz.org\/hbr\/?p=1173\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Bug review, 2013-03-26&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,26],"tags":[],"_links":{"self":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts\/1173"}],"collection":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1173"}],"version-history":[{"count":6,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts\/1173\/revisions"}],"predecessor-version":[{"id":1179,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=\/wp\/v2\/posts\/1173\/revisions\/1179"}],"wp:attachment":[{"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brnz.org\/hbr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}