<table><tr><td style="">aaronpuchert added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D15694">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #8C98B8;
          color: #6B748C;
          font-style: italic;
          margin: 4px 0 12px 0;
          padding: 8px 12px;
          background-color: #F8F9FC;">
<div style="font-style: normal;
          padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D15694#330932" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">D15694#330932</a>, <a href="https://phabricator.kde.org/p/rjvbb/" style="
              border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@rjvbb</a> wrote:</div>
<div style="margin: 0;
          padding: 0;
          border: 0;
          color: rgb(107, 116, 140);"><p>My gripe is more with having to change my habits in ways I don't necessarily agree with entirely, and which might interfere with coding in other contexts.<br />
 It may not in KDevelop's code, but that's not all that all of us work on. Coding style and guidelines for KDevelop itself could reflect good practice you'd like to advocate in general.</p></div>
</blockquote>

<p>I would actually advocate for this in general. I'm not sure which other code bases you work on, but I'm pretty sure both changes are consistent with the consensus in the C++ community. (The projects I work on outside of KDE do the same.) Otherwise compiler writers wouldn't implement these warnings. The fallthrough attribute has actually been standardized now.</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>Not that <tt style="background: #ebebeb; font-size: 13px;">[[fallthrough]]</tt> looks so great (esp. when I'm not wearing appropriate sight correction :D) - I'd be curious to know how this will be handled in ObjC (where I think it corresponds to doing something "not-done" twice). BTW, will there be a corresponding C standard that introduces the same keyword, I'd surely hope so?! If not I do wonder if when C++ is going to introduce a switch/case version that's more on par with the version in interpreted languages that can take non-const cases...</p></blockquote>

<p>You can <a href="https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/" class="remarkup-link" target="_blank" rel="noreferrer">use comments</a>, or <tt style="background: #ebebeb; font-size: 13px;">__attribute__((fallthrough))</tt> in C. You probably want to hide the latter behind a macro, so that other compilers don't see it.</p>

<p>Regarding readability: With these changes, every case block ends with either a terminator or a fallthrough annotation. That is easy to verify both by humans and by compilers. And it means that the programmer has to make explicit, hence think about, what should happen when the block ends. I think this a better strategy to guard against accidental fallthroughs, because how do I know if it was intended if there is no annotation, no comment, no indication that it was? This way we are forcing the programmer to be explicit, so whatever happens will be the intended behavior. There is no way to accidentally miss a <tt style="background: #ebebeb; font-size: 13px;">break</tt> anymore.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R32 KDevelop</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D15694">https://phabricator.kde.org/D15694</a></div></div><br /><div><strong>To: </strong>aaronpuchert, KDevelop<br /><strong>Cc: </strong>rjvbb, brauch, mssola, kossebau, kdevelop-devel, glebaccon, antismap, iodelay, vbspam, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd<br /></div>