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

Compiler intrinsic _itof ignores truncation of its argument

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium

      If the intrinsic _itof is passed an argument that is truncated to a size smaller than 32 bits, the compiler may incorrectly discard the truncation. This truncation can occur with a cast to short or a bit-mask to the lower 16 bits.

      For example:

      /*
         build with
         cl6x -mv6600 -O3 -s file.cpp
      */
      #include <stdint.h>
      float bug(uint32_t a, uint32_t b)
      {      
          const uint32_t lo16 = b & 0x0000FFFFU;
          return _itof(lo16);
      }
      

      You'll get

      bug:
      
                 RETNOP          B3,4 
                 MV      .L1X    B4,A4 
      

      The & 0x0000ffff is ignored. So, if the input value has bits set in the upper 16-bits, they are incorrectly part of the result returned from the function.

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

              Created:
              Updated:
              Resolved: