<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1" style="word-wrap:break-word">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">thanks guys for the quick reply,<br>
<br>
yeah, I suspected something like that. The only thing I was surprised about was that there is a Stmt at all inside a switch "label". I mean, if they are just like goto labels, then no statement at all would seem more intuitive.
<br>
<div><br>
<div style="font-size:13px; font-family:Tahoma">
<p class="MsoNormal"><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US">.......................................................................................................................</span><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:black" lang="EN-US"><br>
Per Viberg </span><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US">Senior Engineer</span><span style="font-size:8.5pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US"><br>
Evidente ES East</span><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-US"> AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden
</span><span style="font-size:10pt; font-family:'Tahoma','sans-serif'; color:black" lang="EN-US"></span></p>
<p class="MsoNormal"><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:gray" lang="EN-GB">Phone:    +46 (0)8 402 79 00<br>
Mobile:    +46 (0)70 912 42 52<br>
E-mail:     <a href="mailto:Per.Viberg@evidente.se" target="_blank"><font color="#0000ff">Per.Viberg@evidente.se</font></a>
</span><span style="font-size:8pt; font-family:'Arial','sans-serif'; color:black" lang="EN-GB"><br>
<br>
<a href="http://www.evidente.se" target="_blank"><font color="#0000ff">www.evidente.se</font></a></span></p>
<p class="MsoNormal"><span style="font-size:6pt; font-family:'Arial','sans-serif'" lang="EN-GB">This e-mail, which might contain confidential information, is addressed to the above stated person/company. If you are not the correct addressee, employee or in
 any other way the person concerned, please notify the sender immediately. At the same time, please delete this e-mail and destroy any prints. Thank You.</span></p>
</div>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF813805"><font color="#000000" face="Tahoma" size="2"><b>Från:</b> Jordan Rose [jordan_rose@apple.com]<br>
<b>Skickat:</b> den 10 mars 2014 17:20<br>
<b>Till:</b> Per Viberg<br>
<b>Cc:</b> cfe-dev Developers; Tom Honermann<br>
<b>Ämne:</b> Re: [cfe-dev] SwitchStmt bug?<br>
</font><br>
</div>
<div></div>
<div><br>
<div>
<div>On Mar 10, 2014, at 7:49 , Tom Honermann <<a href="mailto:thonermann@coverity.com" target="_blank">thonermann@coverity.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">On 03/10/2014 10:23 AM, Per Viberg wrote:<br>
<blockquote type="cite"><br>
Hi all,<br>
<br>
I was inspecting the AST dump of this switch:<br>
<br>
void test_switch(int t) {<br>
  switch(t)<br>
  {<br>
  case 1:<br>
    y = 11;<br>
  case 2:<br>
    y = 9;<br>
    x = 12;<br>
    break;<br>
  default:<br>
    break;<br>
  }<br>
}<br>
<br>
and I got something I didn't expect. The second CaseStmt does only<br>
contain the first statement that is under it's label. The "x=12;" gets<br>
its own Stmt outside the CaseStmt but inside the CompoundStmt inside the<br>
SwitchStmt. I would anticipate that all statements under a label either<br>
are: inside the CaseStmt or: outside but inside the CompoundStmt. Any<br>
reason for this?.<br>
</blockquote>
<br>
This is expected.  Case statements have just one sub statement.<br>
</blockquote>
</div>
<br>
<div>More generally, case statements are just labels, and have the same basic rules as regular old goto labels. Having case statements "just" be labels is what allows things like <a href="http://en.wikipedia.org/wiki/Duff's_device" target="_blank">Duff's Device</a> in
 C:</div>
<div><br>
</div>
<div>switch(count % 8) {<span class="Apple-tab-span" style="white-space:pre"> </span>
<br>
case 0:<span class="Apple-tab-span" style="white-space:pre"> </span>do {<span class="Apple-tab-span" style="white-space:pre">
</span>*to = *from++;<br>
case 7:<span class="Apple-tab-span" style="white-space:pre"> </span>*to = *from++;<br>
case 6:<span class="Apple-tab-span" style="white-space:pre"> </span>*to = *from++;<br>
case 5:<span class="Apple-tab-span" style="white-space:pre"> </span>*to = *from++;<br>
case 4:<span class="Apple-tab-span" style="white-space:pre"> </span>*to = *from++;<br>
case 3:<span class="Apple-tab-span" style="white-space:pre"> </span>*to = *from++;<br>
case 2:<span class="Apple-tab-span" style="white-space:pre"> </span>*to = *from++;<br>
case 1:<span class="Apple-tab-span" style="white-space:pre"> </span>*to = *from++;<br>
<span class="Apple-tab-span" style="white-space:pre"></span>} while(--n > 0);<br>
}</div>
<div><br>
</div>
<div>This is the opposite situation, really, because here we need cases <i>inside</i> the loop that's inside the switch. But once you're supporting this, the representation as a simple label is just easier to work with.</div>
<div><br>
</div>
<div>Jordan<br>
<br>
</div>
</div>
</div>
</div>
</body>
</html>