{"id":37,"date":"2012-11-19T19:00:57","date_gmt":"2012-11-19T18:00:57","guid":{"rendered":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/?p=37"},"modified":"2014-10-11T22:27:47","modified_gmt":"2014-10-11T21:27:47","slug":"infinite-loop-bug","status":"publish","type":"post","link":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/infinite-loop-bug\/","title":{"rendered":"An infinite loop bug"},"content":{"rendered":"<p>It&#8217;s the coolest infinite loop I had ever fallen into:<\/p>\n<p><code>for(char c = 0; c &lt;= 127; c++) {...}<\/code><\/p>\n<p>I wonder how I&#8217;m supposed to perform the intended iterations without obfuscating the code. Sure, I can just drop <strong><code>char<\/code><\/strong> and use <strong><code>int<\/code><\/strong> instead, but this does not solve the problem in general.<\/p>\n<p>P.S.: There seem to be no syntax primitive to safely iterate over an interval [L; U] in languages from the C\/Java family. This means that you just cannot write code <code>for(T c = L; c &lt;= U; c++) {...}<\/code> without making assumptions on T and U.<\/p>\n<p>P.P.S.: Pascal rules! Code <code>for c:= 0 to 255 do begin ... end<\/code>, where <code>c<\/code> is a <strong><code>byte<\/code><\/strong> works just fine \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s the coolest infinite loop I had ever fallen into: for(char c = 0; c &lt;= 127; c++) {&#8230;} I wonder how I&#8217;m supposed to perform the intended iterations without obfuscating the code. Sure, I can just drop char and use int instead, but this does not solve the problem in general. P.S.: There seem &hellip; <a href=\"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/infinite-loop-bug\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">An infinite loop bug<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1174,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[7,8],"class_list":["post-37","post","type-post","status-publish","format-standard","hentry","category-coding","tag-bugs","tag-c"],"_links":{"self":[{"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/users\/1174"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/comments?post=37"}],"version-history":[{"count":5,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/posts\/37\/revisions"}],"predecessor-version":[{"id":65,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/posts\/37\/revisions\/65"}],"wp:attachment":[{"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/media?parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/categories?post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/andreymokhov\/wp-json\/wp\/v2\/tags?post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}