<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>CodeWarrior for MCU中的主题 Error upon incrementing 8bit variable using CW10.7</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Error-upon-incrementing-8bit-variable-using-CW10-7/m-p/809121#M14788</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello folks,&lt;/P&gt;&lt;P&gt;I have encountered a strange problem while using CodeWarrior v10.7 with S12.&lt;/P&gt;&lt;P&gt;TLDR: under certain circumstances the increment operator (++) used on a 8bit uint compiles to inc.w and therefore the variable allocating the next byte in the memory gets incremented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The structure containing the variables:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="struct.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64185i9C6B4F28EB9122D5/image-size/large?v=v2&amp;amp;px=999" role="button" title="struct.png" alt="struct.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The segment of the code in question:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="code.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64355iAF32DCF0DDBCE08D/image-size/large?v=v2&amp;amp;px=999" role="button" title="code.png" alt="code.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;test_var&amp;nbsp;&lt;/EM&gt;is a variable mirroring all the operations of the FilterCounter. The only difference is, that it is declared as a static uint8 inside of the function, while the structure from above is declared as static in the .c file (outside of any function)&lt;/P&gt;&lt;P&gt;So, if I compile the code I get the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="incw.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64398iD803CCB9FB24B414/image-size/large?v=v2&amp;amp;px=999" role="button" title="incw.png" alt="incw.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;(test_var++ is also there, but it is in a different address)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason because I do think this is a bug is, that if I switch the if statement to the one containing &lt;EM&gt;test_var&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="code2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64312i78C839DBA31C923D/image-size/large?v=v2&amp;amp;px=999" role="button" title="code2.png" alt="code2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is what I get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="incb.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64443iC4EB788FF0E489EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="incb.png" alt="incb.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;(also, it does not need to jump in order to increment the second variable)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible to force the 8-bit behaviour by declaring the variable as&lt;/P&gt;&lt;DIV style="color: #000000; background-color: #ffffff; font-family: Consolas, 'Courier New', monospace; font-weight: normal; font-size: 14px; line-height: 19px; white-space: pre;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #000000;"&gt;uint8 DryRunFilterCounter:8;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;In this case the code compiles to the following, independent of which of the if condition are being used:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="uint8_8.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64493iFC09A104870005E3/image-size/large?v=v2&amp;amp;px=999" role="button" title="uint8_8.png" alt="uint8_8.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for now, I can go with the latter, but I do not think this would be an intended behaviour. Can anyone reproduce this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11px;"&gt;As for the screenshots; I know it is strange, but my company guidline does not allow me to share source code, in any form. This is already 'grey zone'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Nov 2018 09:24:13 GMT</pubDate>
    <dc:creator>gellertbalogh</dc:creator>
    <dc:date>2018-11-07T09:24:13Z</dc:date>
    <item>
      <title>Error upon incrementing 8bit variable using CW10.7</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Error-upon-incrementing-8bit-variable-using-CW10-7/m-p/809121#M14788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello folks,&lt;/P&gt;&lt;P&gt;I have encountered a strange problem while using CodeWarrior v10.7 with S12.&lt;/P&gt;&lt;P&gt;TLDR: under certain circumstances the increment operator (++) used on a 8bit uint compiles to inc.w and therefore the variable allocating the next byte in the memory gets incremented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The structure containing the variables:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="struct.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64185i9C6B4F28EB9122D5/image-size/large?v=v2&amp;amp;px=999" role="button" title="struct.png" alt="struct.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The segment of the code in question:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="code.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64355iAF32DCF0DDBCE08D/image-size/large?v=v2&amp;amp;px=999" role="button" title="code.png" alt="code.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;test_var&amp;nbsp;&lt;/EM&gt;is a variable mirroring all the operations of the FilterCounter. The only difference is, that it is declared as a static uint8 inside of the function, while the structure from above is declared as static in the .c file (outside of any function)&lt;/P&gt;&lt;P&gt;So, if I compile the code I get the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="incw.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64398iD803CCB9FB24B414/image-size/large?v=v2&amp;amp;px=999" role="button" title="incw.png" alt="incw.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;(test_var++ is also there, but it is in a different address)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason because I do think this is a bug is, that if I switch the if statement to the one containing &lt;EM&gt;test_var&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="code2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64312i78C839DBA31C923D/image-size/large?v=v2&amp;amp;px=999" role="button" title="code2.png" alt="code2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is what I get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="incb.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64443iC4EB788FF0E489EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="incb.png" alt="incb.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;(also, it does not need to jump in order to increment the second variable)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible to force the 8-bit behaviour by declaring the variable as&lt;/P&gt;&lt;DIV style="color: #000000; background-color: #ffffff; font-family: Consolas, 'Courier New', monospace; font-weight: normal; font-size: 14px; line-height: 19px; white-space: pre;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #000000;"&gt;uint8 DryRunFilterCounter:8;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;In this case the code compiles to the following, independent of which of the if condition are being used:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="uint8_8.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64493iFC09A104870005E3/image-size/large?v=v2&amp;amp;px=999" role="button" title="uint8_8.png" alt="uint8_8.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for now, I can go with the latter, but I do not think this would be an intended behaviour. Can anyone reproduce this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11px;"&gt;As for the screenshots; I know it is strange, but my company guidline does not allow me to share source code, in any form. This is already 'grey zone'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2018 09:24:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Error-upon-incrementing-8bit-variable-using-CW10-7/m-p/809121#M14788</guid>
      <dc:creator>gellertbalogh</dc:creator>
      <dc:date>2018-11-07T09:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: Error upon incrementing 8bit variable using CW10.7</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Error-upon-incrementing-8bit-variable-using-CW10-7/m-p/809122#M14789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi gellertbalogh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you share a simple project to reproduce this behavior?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Jorge Alcala&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2018 18:55:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Error-upon-incrementing-8bit-variable-using-CW10-7/m-p/809122#M14789</guid>
      <dc:creator>jorge_a_vazquez</dc:creator>
      <dc:date>2018-11-15T18:55:55Z</dc:date>
    </item>
  </channel>
</rss>

