This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TMS320F28377D: "Illegal use of intrinsic: __f32toi16r" and "Illegal use of intrinsic: __f32toui16r" on sign mismatch of variable assignment

Part Number: TMS320F28377D

Tool/software: TI C/C++ Compiler

The code snippet:

void test_signed_unsigned_type_mismatch( const double * restrict f32, unsigned int * restrict i16, int num )
{
    for ( ; num > 0; num-- )
    {
        *i16++ = __f32toi16r( *f32++ );
    }
}

compiled with the command:

"C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.9.3.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 -O4 --opt_for_speed=5 --fp_mode=relaxed --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.9.3.LTS/include" --advice:performance=all --define=_INLINE -g --c99 --diag_warning=225 --diag_wrap=off --display_error_number --gen_func_subsections=on --sat_reassoc=on --asm_listing --src_interlist --gen_func_info_listing --gen_opt_info=1 --gen_preprocessor_listing --section_sizes=on --preproc_with_compile --preproc_dependency="f32toi16r.d" "../f32toi16r.c"

gives the error:

error #99923: "../f32toi16r.c", line 5: Illegal use of intrinsic: __f32toi16r

The code snippet:

void test_signed_unsigned_type_mismatch( const double * restrict f32, int * restrict i16, int num )
{
    for ( ; num > 0; num-- )
    {
        *i16++ = __f32toui16r( *f32++ );
    }
}

 

compiled with the command:

"C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.9.3.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 -O4 --opt_for_speed=5 --fp_mode=relaxed --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_16.9.3.LTS/include" --advice:performance=all --define=_INLINE -g --c99 --diag_warning=225 --diag_wrap=off --display_error_number --gen_func_subsections=on --sat_reassoc=on --asm_listing --src_interlist --gen_func_info_listing --gen_opt_info=1 --gen_preprocessor_listing --section_sizes=on --preproc_with_compile --preproc_dependency="f32toi16r.d" "../f32toi16r.c"

gives the error:

error #99923: "../f32toi16r.c", line 5: Illegal use of intrinsic: __f32toui16r

The code snippets:

void test_no_sign_mismatch( const double * restrict f32, unsigned int * restrict i16, int num )
{
    for ( ; num > 0; num-- )
    {
        *i16++ = __f32toui16r( *f32++ );
    }
}

and:

void test_no_sign_mismatch( const double * restrict f32, int * restrict i16, int num )
{
    for ( ; num > 0; num-- )
    {
        *i16++ = __f32toi16r( *f32++ );
    }
}

successfully compile. 

For signed to unsigned the result is specified in the C standard as the result modulo 65536. For the unsigned to signed it is defined if the number unsigned number is in the signed range and implementation defined if the unsigned number is out of the integer range.

Why does a return type and assignment type mismatch cause a compiler error?