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

Compiler generates incorrect code for loop that contains union-based type punning

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Not Prioritized Not Prioritized

      The attached file.cpp has a loop that uses type punning, via a union, to copy the high or low part of int32_t elements from an input array into int16_t elements of an output array. However, the loop does not advance through the input array.

      Build the attached file ...

      $ cl6x -mv6600 -o -s file.cpp
      

      These are the compiler generated comments for the inner loop ...

      ;**     -----------------------g3:
      ;** 16  -----------------------    *U$27++ = U$25;
      ;** 13  -----------------------    if ( L$1 = L$1-1 ) goto g3;
      

      U$27 advances through the output array. But there is no corresponding pointer to advance through the input array.

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

              Created:
              Updated:
              Resolved: