[EXT_EP-11070] Compiler intrinsic _itof ignores truncation of its argument Created: 21/Feb/23  Updated: 03/Nov/25  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.2.0
C6000_8.3.0
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 Sat Dec 13 11:30:53 CST 2025 using Jira 10.3.7#10030007-sha1:a563685562f94d165eb4e158cfb2a142338d8c54.