[EXT_EP-11070] Compiler intrinsic _itof ignores truncation of its argument Created: 21/Feb/23  Updated: 01/Apr/24  Resolved: 03/Aug/23

Status: Fixed
Project: Embedded Software & Tools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Medium
Reporter: TI User Assignee: TI User
Resolution: Fixed Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Product: Code Generation Tools
Internal ID: CODEGEN-10927
Forum URL: https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/81/t/1198153
Found In Release: C6000_8.3.12
Fix In Release: C6000_8.3.13
Affected Platform/Device: default

 Description   

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.


Generated at Wed Apr 16 07:41:26 CDT 2025 using Jira 9.12.17#9120017-sha1:aba4002bcd633f188b6a4bb5dd8a0e1f20b79ee4.