Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-11550

Introducing temp variable causes different result to be computed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Not Prioritized Not Prioritized

      The attached file no_tmp.c has these lines ...

          for (signed int loopIdx = 0; loopIdx < 6; loopIdx++) {
              __int16 vJamFlg = *((__int16 *)(&jamFlg[offset]));
              vbJamFlg[loopIdx] = __cmp_eq_bool(vJamFlg, vOnes);
              __bool16 vbValidFlg = __and(__negate(vbJamFlg[loopIdx]), vbFlg);
              res += (signed int)vbValidFlg.s[0];
              offset += length;
          }
      

      The attached file uses_tmp.c has code that is similar, but introduces a variable vbTmp that is used in place of vbJamFlg[loopIdx] in a few places.

          for (signed int loopIdx = 0; loopIdx < 6; loopIdx++) {
              __int16 vJamFlg = *((__int16 *)(&jamFlg[offset]));
              vbTmp = __cmp_eq_bool(vJamFlg, vOnes);
              __bool16 vbValidFlg = __and(__negate(vbTmp), vbFlg);
              res += (signed int)vbValidFlg.s[0];
              vbJamFlg[loopIdx] = vbTmp;
              offset += length;
          }
      

      Build ...

      $ cl7x -@options.txt no_tmp.c uses_tmp.c
      [no_tmp.c]
      [uses_tmp.c]
      

      The same result should be computed into vbJamFlg[]. But it isn't.

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: